home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / yamp2.zip / VMATRIX.TEX < prev    next >
LaTeX Document  |  1992-01-11  |  17.7 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: LaTeX Document (document/latex).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert Corel 10 Texture (image/corel10Texture) ext Unsupported
1% dexvert Text File (text/txt) fallback Supported
100% file C++ source text default
99% file LaTeX document text default
98% file LaTeX document, ASCII text, with CRLF line terminators default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% detectItEasy Format: plain text[CRLF] default (weak)



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 63 68 61 70 74 65 72 | 7b 56 69 72 74 75 61 6c |\chapter|{Virtual|
|00000010| 20 4d 61 74 72 69 63 65 | 73 7d 0d 0a 0d 0a 0d 0a | Matrice|s}......|
|00000020| 49 6e 20 74 68 65 20 76 | 69 72 74 75 61 6c 20 6d |In the v|irtual m|
|00000030| 65 6d 6f 72 79 20 76 65 | 72 73 69 6f 6e 2c 20 74 |emory ve|rsion, t|
|00000040| 68 65 20 76 69 72 74 75 | 61 6c 20 6d 61 74 72 69 |he virtu|al matri|
|00000050| 78 0d 0a 63 6c 73 61 73 | 73 5c 69 6e 64 65 78 7b |x..clsas|s\index{|
|00000060| 56 4d 61 74 72 69 78 20 | 7d 20 69 73 20 64 65 72 |VMatrix |} is der|
|00000070| 69 76 65 64 20 66 72 6f | 6d 20 74 68 65 20 76 69 |ived fro|m the vi|
|00000080| 72 74 75 61 6c 20 76 65 | 63 74 6f 72 2e 20 54 68 |rtual ve|ctor. Th|
|00000090| 75 73 2c 0d 0a 62 65 66 | 6f 72 65 20 74 68 65 20 |us,..bef|ore the |
|000000a0| 56 4d 61 74 72 69 78 20 | 69 73 20 63 6f 6e 73 74 |VMatrix |is const|
|000000b0| 72 75 63 74 65 64 2c 20 | 74 68 65 20 63 6f 6e 73 |ructed, |the cons|
|000000c0| 74 72 75 63 74 6f 72 20 | 66 6f 72 20 61 20 76 64 |tructor |for a vd|
|000000d0| 6f 75 62 0d 0a 69 73 20 | 63 61 6c 6c 65 64 2e 20 |oub..is |called. |
|000000e0| 54 68 65 20 6d 65 6d 62 | 65 72 73 20 6f 66 20 76 |The memb|ers of v|
|000000f0| 64 6f 75 62 20 61 72 65 | 20 70 72 69 76 61 74 65 |doub are| private|
|00000100| 20 74 6f 20 74 68 65 20 | 56 4d 61 74 72 69 78 0d | to the |VMatrix.|
|00000110| 0a 63 6c 61 73 73 2c 20 | 73 6f 20 74 68 65 79 20 |.class, |so they |
|00000120| 61 72 65 20 61 76 61 69 | 6c 61 62 6c 65 20 74 6f |are avai|lable to|
|00000130| 20 74 68 65 20 6d 65 6d | 62 65 72 20 66 75 6e 63 | the mem|ber func|
|00000140| 74 69 6f 6e 73 20 6f 66 | 20 56 4d 61 74 72 69 78 |tions of| VMatrix|
|00000150| 2e 0d 0a 54 68 65 20 6d | 61 74 72 69 78 20 63 6c |...The m|atrix cl|
|00000160| 61 73 73 20 73 74 6f 72 | 65 73 20 69 74 73 20 65 |ass stor|es its e|
|00000170| 6c 65 6d 65 6e 74 73 20 | 69 6e 20 61 20 76 69 72 |lements |in a vir|
|00000180| 74 75 61 6c 20 76 65 63 | 74 6f 72 20 69 6e 20 72 |tual vec|tor in r|
|00000190| 6f 77 0d 0a 6d 61 6a 6f | 72 20 6f 72 64 65 72 2e |ow..majo|r order.|
|000001a0| 20 54 68 61 74 20 69 73 | 2c 20 74 68 65 20 72 6f | That is|, the ro|
|000001b0| 77 73 20 6f 66 20 74 68 | 65 20 6d 61 74 72 69 78 |ws of th|e matrix|
|000001c0| 20 61 72 65 20 73 74 6f | 72 65 64 0d 0a 73 65 71 | are sto|red..seq|
|000001d0| 75 65 6e 74 69 61 6c 6c | 79 20 69 6e 20 74 68 65 |uentiall|y in the|
|000001e0| 20 76 65 63 74 6f 72 2e | 20 41 63 63 65 73 73 20 | vector.| Access |
|000001f0| 61 6e 64 20 73 74 6f 72 | 61 67 65 20 6f 66 20 74 |and stor|age of t|
|00000200| 68 65 20 6d 61 74 72 69 | 78 0d 0a 65 6c 65 6d 65 |he matri|x..eleme|
|00000210| 6e 74 73 20 69 73 20 61 | 63 68 69 65 76 65 64 20 |nts is a|chieved |
|00000220| 74 68 72 6f 75 67 68 20 | 76 64 6f 75 62 3a 3a 6f |through |vdoub::o|
|00000230| 70 65 72 61 74 6f 72 5b | 5d 2e 0d 0a 0d 0a 41 20 |perator[|].....A |
|00000240| 66 75 6c 6c 20 73 65 74 | 20 6f 66 20 66 75 6e 63 |full set| of func|
|00000250| 74 69 6f 6e 73 20 69 73 | 20 63 72 65 61 74 65 64 |tions is| created|
|00000260| 20 66 6f 72 20 74 68 65 | 20 6d 61 74 72 69 78 20 | for the| matrix |
|00000270| 63 6c 61 73 73 2e 0d 0a | 41 73 73 69 67 6e 6d 65 |class...|Assignme|
|00000280| 6e 74 20 6f 66 20 6d 61 | 74 72 69 63 65 73 20 61 |nt of ma|trices a|
|00000290| 6e 64 20 65 6c 65 6d 65 | 6e 74 73 20 69 73 20 64 |nd eleme|nts is d|
|000002a0| 65 76 65 6c 6f 70 65 64 | 2e 20 46 75 6e 63 74 69 |eveloped|. Functi|
|000002b0| 6f 6e 73 0d 0a 61 72 65 | 20 61 6c 73 6f 20 63 72 |ons..are| also cr|
|000002c0| 65 61 74 65 64 20 66 6f | 72 0d 0a 5c 62 65 67 69 |eated fo|r..\begi|
|000002d0| 6e 7b 65 6e 75 6d 65 72 | 61 74 65 7d 0d 0a 20 5c |n{enumer|ate}.. \|
|000002e0| 69 74 65 6d 20 6d 61 6e | 69 70 75 6c 61 74 69 6e |item man|ipulatin|
|000002f0| 67 20 74 68 65 20 6d 61 | 74 72 69 78 20 6e 61 6d |g the ma|trix nam|
|00000300| 65 2c 20 0d 0a 20 5c 69 | 74 65 6d 20 66 6f 72 20 |e, .. \i|tem for |
|00000310| 64 69 73 70 6c 61 79 69 | 6e 67 20 6d 61 74 72 69 |displayi|ng matri|
|00000320| 78 20 69 6e 66 6f 72 6d | 61 74 69 6f 6e 2c 20 0d |x inform|ation, .|
|00000330| 0a 20 5c 69 74 65 6d 20 | 66 6f 72 20 61 72 69 74 |. \item |for arit|
|00000340| 68 6d 65 74 69 63 20 6f | 70 65 72 61 74 69 6f 6e |hmetic o|peration|
|00000350| 73 2c 0d 0a 20 5c 69 74 | 65 6d 20 66 6f 72 20 64 |s,.. \it|em for d|
|00000360| 61 74 61 20 69 6f 2c 20 | 0d 0a 20 5c 69 74 65 6d |ata io, |.. \item|
|00000370| 20 66 6f 72 20 6d 61 74 | 72 69 78 20 66 75 6e 63 | for mat|rix func|
|00000380| 74 69 6f 6e 73 2c 20 0d | 0a 20 5c 69 74 65 6d 20 |tions, .|. \item |
|00000390| 66 6f 72 20 72 65 63 75 | 72 73 69 76 65 20 63 61 |for recu|rsive ca|
|000003a0| 6c 63 75 6c 61 74 69 6f | 6e 73 2c 20 0d 0a 20 5c |lculatio|ns, .. \|
|000003b0| 69 74 65 6d 20 61 6e 64 | 20 6e 65 73 74 65 64 20 |item and| nested |
|000003c0| 66 75 6e 63 74 69 6f 6e | 20 63 61 6c 6c 73 2e 20 |function| calls. |
|000003d0| 20 0d 0a 5c 65 6e 64 7b | 65 6e 75 6d 65 72 61 74 | ..\end{|enumerat|
|000003e0| 65 7d 0d 0a 4d 75 63 68 | 20 6f 66 20 74 68 69 73 |e}..Much| of this|
|000003f0| 20 69 73 20 61 63 63 6f | 6d 70 6c 69 73 68 65 64 | is acco|mplished|
|00000400| 20 75 73 69 6e 67 20 61 | 20 73 74 61 63 6b 20 6f | using a| stack o|
|00000410| 66 20 76 69 72 74 75 61 | 6c 20 6d 61 74 72 69 63 |f virtua|l matric|
|00000420| 65 73 0d 0a 77 68 69 63 | 68 20 77 69 6c 6c 20 62 |es..whic|h will b|
|00000430| 65 20 64 69 73 63 75 73 | 73 65 64 20 69 6e 20 6d |e discus|sed in m|
|00000440| 6f 72 65 20 64 65 74 61 | 69 6c 20 6c 61 74 65 72 |ore deta|il later|
|00000450| 2e 20 46 6f 72 20 6e 6f | 77 2c 20 69 74 20 69 73 |. For no|w, it is|
|00000460| 0d 0a 73 75 66 66 69 63 | 69 65 6e 74 20 74 6f 20 |..suffic|ient to |
|00000470| 73 61 79 20 74 68 61 74 | 20 74 68 65 20 6d 61 74 |say that| the mat|
|00000480| 72 69 78 20 73 74 61 63 | 6b 20 69 73 20 61 20 64 |rix stac|k is a d|
|00000490| 65 72 69 76 65 64 20 63 | 6c 61 73 73 20 6f 66 0d |erived c|lass of.|
|000004a0| 0a 56 4d 61 74 72 69 78 | 2c 20 62 75 74 20 6d 61 |.VMatrix|, but ma|
|000004b0| 6e 79 20 6f 66 20 74 68 | 65 20 70 75 62 6c 69 63 |ny of th|e public|
|000004c0| 20 66 75 6e 63 74 69 6f | 6e 73 20 6f 66 20 74 68 | functio|ns of th|
|000004d0| 65 20 73 74 61 63 6b 20 | 63 6c 61 73 73 20 61 72 |e stack |class ar|
|000004e0| 65 0d 0a 75 73 65 64 20 | 69 6e 20 56 4d 61 74 72 |e..used |in VMatr|
|000004f0| 69 78 2e 20 54 68 75 73 | 20 74 68 65 20 74 77 6f |ix. Thus| the two|
|00000500| 20 63 6c 61 73 73 65 73 | 20 66 6f 72 6d 20 73 6f | classes| form so|
|00000510| 6d 65 74 68 69 6e 67 20 | 6f 66 20 61 0d 0a 73 79 |mething |of a..sy|
|00000520| 6d 62 69 6f 73 69 73 20 | 72 61 74 68 65 72 20 74 |mbiosis |rather t|
|00000530| 68 61 6e 20 61 20 73 74 | 72 69 63 74 20 68 69 65 |han a st|rict hie|
|00000540| 72 61 72 63 68 79 2e 20 | 20 54 68 65 20 73 74 61 |rarchy. | The sta|
|00000550| 63 6b 20 62 61 73 65 20 | 69 73 0d 0a 63 61 6c 6c |ck base |is..call|
|00000560| 65 64 20 44 69 73 70 61 | 74 63 68 5c 69 6e 64 65 |ed Dispa|tch\inde|
|00000570| 78 7b 4d 53 74 61 63 6b | 21 44 69 73 70 61 74 63 |x{MStack|!Dispatc|
|00000580| 68 7d 2c 20 61 6e 64 20 | 61 6c 6c 20 6f 74 68 65 |h}, and |all othe|
|00000590| 72 20 73 74 61 63 6b 0d | 0a 6d 61 74 72 69 63 65 |r stack.|.matrice|
|000005a0| 73 20 61 72 65 20 75 6e | 61 63 63 65 73 73 69 62 |s are un|accessib|
|000005b0| 6c 65 20 74 6f 20 6f 74 | 68 65 72 20 66 75 6e 63 |le to ot|her func|
|000005c0| 74 69 6f 6e 73 2e 0d 0a | 0d 0a 5c 73 65 63 74 69 |tions...|..\secti|
|000005d0| 6f 6e 7b 54 68 65 20 44 | 65 63 6c 61 72 61 74 69 |on{The D|eclarati|
|000005e0| 6f 6e 20 6f 66 20 74 68 | 65 20 56 4d 61 74 72 69 |on of th|e VMatri|
|000005f0| 78 20 43 6c 61 73 73 7d | 0d 0a 0d 0a 54 68 65 20 |x Class}|....The |
|00000600| 76 69 72 74 75 61 6c 20 | 6d 61 74 72 69 78 20 56 |virtual |matrix V|
|00000610| 4d 61 74 72 69 78 20 63 | 6c 61 73 73 20 69 73 20 |Matrix c|lass is |
|00000620| 63 72 65 61 74 65 64 20 | 62 79 20 74 68 65 20 66 |created |by the f|
|00000630| 6f 6c 6c 6f 77 69 6e 67 | 20 64 65 63 6c 61 72 61 |ollowing| declara|
|00000640| 74 69 6f 6e 0d 0a 5c 62 | 65 67 69 6e 7b 76 65 72 |tion..\b|egin{ver|
|00000650| 62 61 74 69 6d 7d 0d 0a | 63 6c 61 73 73 20 56 4d |batim}..|class VM|
|00000660| 61 74 72 69 78 20 3a 20 | 70 72 69 76 61 74 65 20 |atrix : |private |
|00000670| 76 64 6f 75 62 0d 0a 20 | 7b 0d 0a 0d 0a 20 70 72 |vdoub.. |{.... pr|
|00000680| 6f 74 65 63 74 65 64 3a | 0d 0a 20 20 20 75 6e 73 |otected:|.. uns|
|00000690| 69 67 6e 65 64 20 73 69 | 67 6e 61 74 75 72 65 3b |igned si|gnature;|
|000006a0| 0d 0a 20 20 20 6c 6f 6e | 67 20 6d 69 6e 64 65 78 |.. lon|g mindex|
|000006b0| 28 20 69 6e 74 20 69 2c | 20 69 6e 74 20 6a 29 7b |( int i,| int j){|
|000006c0| 0d 0a 20 20 20 20 20 20 | 20 20 72 65 74 75 72 6e |.. | return|
|000006d0| 20 20 20 28 6c 6f 6e 67 | 29 20 28 28 28 6c 6f 6e | (long|) (((lon|
|000006e0| 67 29 28 69 2d 31 29 29 | 2a 28 28 6c 6f 6e 67 29 |g)(i-1))|*((long)|
|000006f0| 63 29 2b 28 28 6c 6f 6e | 67 29 28 6a 2d 31 29 29 |c)+((lon|g)(j-1))|
|00000700| 29 20 3b 20 7d 0d 0a 20 | 20 20 6c 6f 6e 67 20 63 |) ; }.. | long c|
|00000710| 75 72 76 65 63 69 6e 64 | 3b 20 20 20 20 20 20 20 |urvecind|; |
|00000720| 2f 2f 20 63 75 72 72 65 | 6e 74 20 69 6e 64 65 78 |// curre|nt index|
|00000730| 20 66 6f 72 20 76 65 63 | 74 6f 72 0d 0a 20 20 20 | for vec|tor.. |
|00000740| 73 74 72 74 79 70 65 20 | 6e 61 6d 65 3b 0d 0a 20 |strtype |name;.. |
|00000750| 20 20 76 6f 69 64 20 53 | 65 74 75 70 56 65 63 74 | void S|etupVect|
|00000760| 6f 72 73 28 20 69 6e 74 | 20 72 72 3d 31 2c 20 69 |ors( int| rr=1, i|
|00000770| 6e 74 20 63 63 3d 31 20 | 29 3b 0d 0a 20 20 20 76 |nt cc=1 |);.. v|
|00000780| 6f 69 64 20 50 75 72 67 | 65 56 65 63 74 6f 72 73 |oid Purg|eVectors|
|00000790| 28 20 76 6f 69 64 20 29 | 3b 0d 0a 20 20 20 76 6f |( void )|;.. vo|
|000007a0| 69 64 20 52 65 70 6c 61 | 63 65 28 20 56 4d 61 74 |id Repla|ce( VMat|
|000007b0| 72 69 78 20 26 52 4f 70 | 20 29 3b 0d 0a 20 20 20 |rix &ROp| );.. |
|000007c0| 76 6f 69 64 20 4e 65 77 | 52 65 66 65 72 65 6e 63 |void New|Referenc|
|000007d0| 65 28 56 4d 61 74 72 69 | 78 20 26 52 4f 70 20 29 |e(VMatri|x &ROp )|
|000007e0| 3b 0d 0a 0d 0a 20 70 75 | 62 6c 69 63 3a 0d 0a 0d |;.... pu|blic:...|
|000007f0| 0a 20 20 20 64 6f 75 62 | 6c 65 20 4e 72 65 72 72 |. doub|le Nrerr|
|00000800| 6f 72 28 20 63 6f 6e 73 | 74 20 63 68 61 72 20 2a |or( cons|t char *|
|00000810| 65 72 72 6f 72 6d 73 67 | 20 29 3b 0d 0a 20 20 20 |errormsg| );.. |
|00000820| 76 6f 69 64 20 47 61 72 | 62 61 67 65 28 20 63 6f |void Gar|bage( co|
|00000830| 6e 73 74 20 63 68 61 72 | 20 2a 65 72 72 6f 72 6d |nst char| *errorm|
|00000840| 73 67 29 3b 0d 0a 20 20 | 20 76 6f 69 64 20 47 61 |sg);.. | void Ga|
|00000850| 72 62 61 67 65 28 20 76 | 6f 69 64 20 29 7b 20 47 |rbage( v|oid ){ G|
|00000860| 61 72 62 61 67 65 28 22 | 20 22 29 3b 7d 0d 0a 20 |arbage("| ");}.. |
|00000870| 20 20 69 6e 74 20 72 2c | 63 3b 0d 0a 0d 0a 20 20 | int r,|c;.... |
|00000880| 20 64 6f 75 62 6c 65 20 | 6d 28 20 69 6e 74 20 69 | double |m( int i|
|00000890| 2c 20 69 6e 74 20 6a 20 | 29 20 7b 20 20 20 20 20 |, int j |) { |
|000008a0| 20 20 20 20 20 2f 2f 20 | 67 65 74 20 61 20 76 61 | // |get a va|
|000008b0| 6c 75 65 0d 0a 20 20 20 | 20 20 20 20 69 66 28 20 |lue.. | if( |
|000008c0| 69 3c 31 20 7c 7c 20 6a | 3c 31 20 7c 7c 20 69 3e |i<1 || j|<1 || i>|
|000008d0| 72 20 7c 7c 20 6a 3e 63 | 20 29 7b 0d 0a 20 20 20 |r || j>c| ){.. |
|000008e0| 20 20 20 20 63 65 72 72 | 20 3c 3c 20 22 69 6e 64 | cerr| << "ind|
|000008f0| 65 78 20 6f 75 74 20 6f | 66 20 72 61 6e 67 65 5c |ex out o|f range\|
|00000900| 6e 22 3b 0d 0a 20 20 20 | 20 20 20 20 65 78 69 74 |n";.. | exit|
|00000910| 28 31 29 3b 0d 0a 20 20 | 20 20 20 20 20 7d 0d 0a |(1);.. | }..|
|00000920| 20 20 20 20 20 20 20 63 | 75 72 76 65 63 69 6e 64 | c|urvecind|
|00000930| 20 3d 20 6d 69 6e 64 65 | 78 28 69 2c 6a 29 3b 0d | = minde|x(i,j);.|
|00000940| 0a 20 20 20 20 20 20 20 | 72 65 74 75 72 6e 20 76 |. |return v|
|00000950| 28 20 63 75 72 76 65 63 | 69 6e 64 20 29 3b 0d 0a |( curvec|ind );..|
|00000960| 20 20 20 7d 0d 0a 20 20 | 20 56 4d 61 74 72 69 78 | }.. | VMatrix|
|00000970| 26 20 4d 28 20 69 6e 74 | 20 69 2c 20 69 6e 74 20 |& M( int| i, int |
|00000980| 6a 20 29 20 7b 20 2f 2f | 20 6c 6f 61 64 20 63 75 |j ) { //| load cu|
|00000990| 72 72 65 6e 74 20 62 75 | 66 66 65 72 0d 0a 20 20 |rrent bu|ffer.. |
|000009a0| 20 20 20 20 20 20 63 75 | 72 76 65 63 69 6e 64 20 | cu|rvecind |
|000009b0| 3d 20 6d 69 6e 64 65 78 | 28 69 2c 6a 29 3b 0d 0a |= mindex|(i,j);..|
|000009c0| 20 20 20 20 20 20 20 20 | 76 64 6f 75 62 3a 3a 6f | |vdoub::o|
|000009d0| 70 65 72 61 74 6f 72 5b | 5d 28 63 75 72 76 65 63 |perator[|](curvec|
|000009e0| 69 6e 64 29 3b 0d 0a 20 | 20 20 20 20 20 20 20 72 |ind);.. | r|
|000009f0| 65 74 75 72 6e 20 2a 74 | 68 69 73 3b 0d 0a 20 20 |eturn *t|his;.. |
|00000a00| 20 7d 0d 0a 0d 0a 20 20 | 20 56 4d 61 74 72 69 78 | }.... | VMatrix|
|00000a10| 28 20 76 6f 69 64 20 29 | 3b 20 20 20 20 20 20 20 |( void )|; |
|00000a20| 20 20 20 20 20 2f 2f 20 | 63 6f 6e 73 74 72 75 63 | // |construc|
|00000a30| 74 6f 72 73 20 61 6e 64 | 20 64 65 73 74 72 75 63 |tors and| destruc|
|00000a40| 74 6f 72 73 0d 0a 20 20 | 20 56 4d 61 74 72 69 78 |tors.. | VMatrix|
|00000a50| 28 20 63 6f 6e 73 74 20 | 63 68 61 72 20 2a 73 74 |( const |char *st|
|00000a60| 72 2c 20 69 6e 74 20 69 | 2c 20 69 6e 74 20 6a 29 |r, int i|, int j)|
|00000a70| 3b 0d 0a 20 20 20 56 4d | 61 74 72 69 78 28 20 56 |;.. VM|atrix( V|
|00000a80| 4d 61 74 72 69 78 20 26 | 56 4d 61 74 72 69 78 20 |Matrix &|VMatrix |
|00000a90| 29 3b 0d 0a 20 20 20 7e | 56 4d 61 74 72 69 78 28 |);.. ~|VMatrix(|
|00000aa0| 20 76 6f 69 64 20 29 3b | 0d 0a 0d 0a 20 20 20 64 | void );|.... d|
|00000ab0| 6f 75 62 6c 65 20 6f 70 | 65 72 61 74 6f 72 20 3d |ouble op|erator =|
|00000ac0| 20 28 20 64 6f 75 62 6c | 65 20 64 20 29 7b 20 20 | ( doubl|e d ){ |
|00000ad0| 20 20 20 2f 2f 20 77 72 | 69 74 65 20 69 6e 20 61 | // wr|ite in a|
|00000ae0| 20 76 61 6c 75 65 0d 0a | 20 20 20 20 20 76 64 6f | value..| vdo|
|00000af0| 75 62 3a 3a 6f 70 65 72 | 61 74 6f 72 5b 5d 28 63 |ub::oper|ator[](c|
|00000b00| 75 72 76 65 63 69 6e 64 | 29 20 3d 20 64 3b 0d 0a |urvecind|) = d;..|
|00000b10| 20 20 20 20 20 72 65 74 | 75 72 6e 20 64 3b 0d 0a | ret|urn d;..|
|00000b20| 20 20 20 7d 0d 0a 20 20 | 20 76 6f 69 64 20 6f 70 | }.. | void op|
|00000b30| 65 72 61 74 6f 72 3d 20 | 28 56 4d 61 74 72 69 78 |erator= |(VMatrix|
|00000b40| 20 26 52 4f 70 29 3b 0d | 0a 0d 0a 20 20 20 76 6f | &ROp);.|... vo|
|00000b50| 69 64 20 4e 61 6d 65 69 | 74 28 20 63 6f 6e 73 74 |id Namei|t( const|
|00000b60| 20 63 68 61 72 20 2a 73 | 74 72 20 29 20 7b 20 6e | char *s|tr ) { n|
|00000b70| 61 6d 65 20 3d 20 73 74 | 72 3b 20 7d 0d 0a 20 20 |ame = st|r; }.. |
|00000b80| 20 76 6f 69 64 20 4e 61 | 6d 65 69 74 28 20 56 4d | void Na|meit( VM|
|00000b90| 61 74 72 69 78 20 26 6d | 61 74 20 29 7b 20 6e 61 |atrix &m|at ){ na|
|00000ba0| 6d 65 20 3d 20 6d 61 74 | 2e 6e 61 6d 65 3b 20 7d |me = mat|.name; }|
|00000bb0| 0d 0a 20 20 20 76 6f 69 | 64 20 4e 61 6d 65 69 74 |.. voi|d Nameit|
|00000bc0| 28 20 73 74 72 74 79 70 | 65 20 6e 65 77 6e 61 6d |( strtyp|e newnam|
|00000bd0| 65 29 7b 20 6e 61 6d 65 | 20 3d 20 6e 65 77 6e 61 |e){ name| = newna|
|00000be0| 6d 65 3b 20 7d 0d 0a 20 | 20 20 73 74 72 74 79 70 |me; }.. | strtyp|
|00000bf0| 65 20 47 65 74 6e 61 6d | 65 28 20 56 4d 61 74 72 |e Getnam|e( VMatr|
|00000c00| 69 78 20 26 6d 61 74 29 | 7b 20 72 65 74 75 72 6e |ix &mat)|{ return|
|00000c10| 20 6d 61 74 2e 6e 61 6d | 65 3b 20 7d 0d 0a 20 20 | mat.nam|e; }.. |
|00000c20| 20 76 6f 69 64 20 53 68 | 6f 77 6e 61 6d 65 28 20 | void Sh|owname( |
|00000c30| 76 6f 69 64 20 29 7b 20 | 6e 61 6d 65 2e 53 68 6f |void ){ |name.Sho|
|00000c40| 77 6e 61 6d 65 28 29 3b | 20 7d 0d 0a 20 20 20 63 |wname();| }.. c|
|00000c50| 68 61 72 20 2a 53 74 72 | 69 6e 67 41 64 64 72 65 |har *Str|ingAddre|
|00000c60| 73 73 28 20 76 6f 69 64 | 20 29 20 7b 20 72 65 74 |ss( void| ) { ret|
|00000c70| 75 72 6e 20 6e 61 6d 65 | 2e 53 74 72 69 6e 67 41 |urn name|.StringA|
|00000c80| 64 64 72 65 73 73 28 29 | 3b 20 7d 0d 0a 0d 0a 20 |ddress()|; }.... |
|00000c90| 20 20 76 6f 69 64 20 4c | 6f 61 64 4d 61 74 28 76 | void L|oadMat(v|
|00000ca0| 6f 69 64 29 3b 0d 0a 20 | 20 20 76 6f 69 64 20 44 |oid);.. | void D|
|00000cb0| 69 73 70 6c 61 79 4d 61 | 74 28 76 6f 69 64 29 3b |isplayMa|t(void);|
|00000cc0| 0d 0a 20 20 20 76 6f 69 | 64 20 49 6e 66 6f 4d 61 |.. voi|d InfoMa|
|00000cd0| 74 28 20 76 6f 69 64 20 | 29 3b 0d 0a 20 20 20 76 |t( void |);.. v|
|00000ce0| 6f 69 64 20 57 72 69 74 | 65 62 20 28 63 68 61 72 |oid Writ|eb (char|
|00000cf0| 20 2a 66 69 64 2c 20 56 | 4d 61 74 72 69 78 20 26 | *fid, V|Matrix &|
|00000d00| 6d 61 74 29 3b 0d 0a 0d | 0a 20 20 20 66 72 69 65 |mat);...|. frie|
|00000d10| 6e 64 20 56 4d 61 74 72 | 69 78 26 20 6f 70 65 72 |nd VMatr|ix& oper|
|00000d20| 61 74 6f 72 2b 20 28 56 | 4d 61 74 72 69 78 20 26 |ator+ (V|Matrix &|
|00000d30| 4c 4f 70 2c 20 56 4d 61 | 74 72 69 78 20 26 52 4f |LOp, VMa|trix &RO|
|00000d40| 70 29 3b 0d 0a 20 20 20 | 66 72 69 65 6e 64 20 56 |p);.. |friend V|
|00000d50| 4d 61 74 72 69 78 26 20 | 6f 70 65 72 61 74 6f 72 |Matrix& |operator|
|00000d60| 2b 20 28 64 6f 75 62 6c | 65 20 73 63 61 6c 61 72 |+ (doubl|e scalar|
|00000d70| 2c 20 56 4d 61 74 72 69 | 78 20 26 52 4f 70 29 3b |, VMatri|x &ROp);|
|00000d80| 0d 0a 20 20 20 66 72 69 | 65 6e 64 20 56 4d 61 74 |.. fri|end VMat|
|00000d90| 72 69 78 26 20 6f 70 65 | 72 61 74 6f 72 2b 20 28 |rix& ope|rator+ (|
|00000da0| 56 4d 61 74 72 69 78 20 | 26 52 4f 70 2c 20 64 6f |VMatrix |&ROp, do|
|00000db0| 75 62 6c 65 20 73 63 61 | 6c 61 72 29 3b 0d 0a 20 |uble sca|lar);.. |
|00000dc0| 20 20 66 72 69 65 6e 64 | 20 56 4d 61 74 72 69 78 | friend| VMatrix|
|00000dd0| 26 20 6f 70 65 72 61 74 | 6f 72 2d 20 28 56 4d 61 |& operat|or- (VMa|
|00000de0| 74 72 69 78 20 26 4c 4f | 70 2c 20 56 4d 61 74 72 |trix &LO|p, VMatr|
|00000df0| 69 78 20 26 52 4f 70 29 | 3b 0d 0a 20 20 20 66 72 |ix &ROp)|;.. fr|
|00000e00| 69 65 6e 64 20 56 4d 61 | 74 72 69 78 26 20 6f 70 |iend VMa|trix& op|
|00000e10| 65 72 61 74 6f 72 2d 20 | 28 64 6f 75 62 6c 65 20 |erator- |(double |
|00000e20| 73 63 61 6c 61 72 2c 20 | 56 4d 61 74 72 69 78 20 |scalar, |VMatrix |
|00000e30| 26 52 4f 70 29 3b 0d 0a | 20 20 20 66 72 69 65 6e |&ROp);..| frien|
|00000e40| 64 20 56 4d 61 74 72 69 | 78 26 20 6f 70 65 72 61 |d VMatri|x& opera|
|00000e50| 74 6f 72 2d 20 28 56 4d | 61 74 72 69 78 20 26 52 |tor- (VM|atrix &R|
|00000e60| 4f 70 2c 20 64 6f 75 62 | 6c 65 20 73 63 61 6c 61 |Op, doub|le scala|
|00000e70| 72 29 3b 0d 0a 20 20 20 | 66 72 69 65 6e 64 20 56 |r);.. |friend V|
|00000e80| 4d 61 74 72 69 78 26 20 | 6f 70 65 72 61 74 6f 72 |Matrix& |operator|
|00000e90| 2d 20 28 56 4d 61 74 72 | 69 78 20 26 52 4f 70 29 |- (VMatr|ix &ROp)|
|00000ea0| 3b 0d 0a 20 20 20 66 72 | 69 65 6e 64 20 56 4d 61 |;.. fr|iend VMa|
|00000eb0| 74 72 69 78 26 20 6f 70 | 65 72 61 74 6f 72 2a 20 |trix& op|erator* |
|00000ec0| 28 56 4d 61 74 72 69 78 | 20 26 4c 4f 70 2c 20 56 |(VMatrix| &LOp, V|
|00000ed0| 4d 61 74 72 69 78 20 26 | 52 4f 70 29 3b 0d 0a 20 |Matrix &|ROp);.. |
|00000ee0| 20 20 66 72 69 65 6e 64 | 20 56 4d 61 74 72 69 78 | friend| VMatrix|
|00000ef0| 26 20 6f 70 65 72 61 74 | 6f 72 2a 20 28 64 6f 75 |& operat|or* (dou|
|00000f00| 62 6c 65 20 73 63 61 6c | 61 72 2c 20 56 4d 61 74 |ble scal|ar, VMat|
|00000f10| 72 69 78 20 26 52 4f 70 | 29 3b 0d 0a 20 20 20 66 |rix &ROp|);.. f|
|00000f20| 72 69 65 6e 64 20 56 4d | 61 74 72 69 78 26 20 6f |riend VM|atrix& o|
|00000f30| 70 65 72 61 74 6f 72 2a | 20 28 56 4d 61 74 72 69 |perator*| (VMatri|
|00000f40| 78 20 26 52 4f 70 2c 20 | 64 6f 75 62 6c 65 20 73 |x &ROp, |double s|
|00000f50| 63 61 6c 61 72 29 3b 0d | 0a 20 20 20 66 72 69 65 |calar);.|. frie|
|00000f60| 6e 64 20 56 4d 61 74 72 | 69 78 26 20 6f 70 65 72 |nd VMatr|ix& oper|
|00000f70| 61 74 6f 72 25 20 28 56 | 4d 61 74 72 69 78 20 26 |ator% (V|Matrix &|
|00000f80| 4c 4f 70 2c 20 56 4d 61 | 74 72 69 78 20 26 52 4f |LOp, VMa|trix &RO|
|00000f90| 70 20 29 3b 0d 0a 20 20 | 20 66 72 69 65 6e 64 20 |p );.. | friend |
|00000fa0| 56 4d 61 74 72 69 78 26 | 20 6f 70 65 72 61 74 6f |VMatrix&| operato|
|00000fb0| 72 2f 20 28 56 4d 61 74 | 72 69 78 20 26 4c 4f 70 |r/ (VMat|rix &LOp|
|00000fc0| 2c 20 56 4d 61 74 72 69 | 78 20 26 52 4f 70 29 3b |, VMatri|x &ROp);|
|00000fd0| 0d 0a 20 20 20 66 72 69 | 65 6e 64 20 56 4d 61 74 |.. fri|end VMat|
|00000fe0| 72 69 78 26 20 6f 70 65 | 72 61 74 6f 72 2f 20 28 |rix& ope|rator/ (|
|00000ff0| 56 4d 61 74 72 69 78 20 | 26 52 4f 70 2c 20 64 6f |VMatrix |&ROp, do|
|00001000| 75 62 6c 65 20 73 63 61 | 6c 61 72 29 3b 0d 0a 7d |uble sca|lar);..}|
|00001010| 3b 0d 0a 5c 65 6e 64 7b | 76 65 72 62 61 74 69 6d |;..\end{|verbatim|
|00001020| 7d 0d 0a 0d 0a 54 68 65 | 20 69 6e 2d 72 61 6d 20 |}....The| in-ram |
|00001030| 76 65 72 73 69 6f 6e 20 | 68 61 73 20 61 20 76 65 |version |has a ve|
|00001040| 72 79 20 73 69 6d 69 6c | 61 72 20 73 74 72 75 63 |ry simil|ar struc|
|00001050| 74 75 72 65 2c 20 62 75 | 74 20 69 73 20 6e 6f 74 |ture, bu|t is not|
|00001060| 0d 0a 64 65 72 69 76 65 | 64 20 66 72 6f 6d 20 61 |..derive|d from a|
|00001070| 6e 79 20 6f 74 68 65 72 | 20 63 6c 61 73 73 2e 20 |ny other| class. |
|00001080| 54 68 65 20 73 79 73 74 | 65 6d 20 73 75 70 70 6c |The syst|em suppl|
|00001090| 69 65 73 20 64 79 6e 61 | 6d 69 63 20 6d 65 6d 6f |ies dyna|mic memo|
|000010a0| 72 79 0d 0a 73 6f 20 74 | 68 65 72 65 20 69 73 20 |ry..so t|here is |
|000010b0| 6e 6f 20 6e 65 65 64 20 | 74 6f 20 65 6e 63 61 70 |no need |to encap|
|000010c0| 73 75 6c 61 74 65 20 74 | 68 65 20 6d 65 6d 6f 72 |sulate t|he memor|
|000010d0| 79 20 6d 61 6e 61 67 65 | 72 20 69 6e 20 61 0d 0a |y manage|r in a..|
|000010e0| 73 65 70 61 72 61 74 65 | 20 63 6c 61 73 73 2e 20 |separate| class. |
|000010f0| 49 6e 20 74 68 65 20 69 | 6e 2d 72 61 6d 20 76 65 |In the i|n-ram ve|
|00001100| 72 73 69 6f 6e 2c 20 6d | 61 74 72 69 63 65 73 20 |rsion, m|atrices |
|00001110| 61 72 65 20 63 6f 6e 73 | 74 72 75 63 74 65 64 0d |are cons|tructed.|
|00001120| 0a 66 72 6f 6d 20 76 65 | 63 74 6f 72 73 20 61 6c |.from ve|ctors al|
|00001130| 6c 6f 63 61 74 65 64 20 | 6f 6e 20 74 68 65 20 68 |located |on the h|
|00001140| 65 61 70 2e 20 54 68 65 | 20 69 6e 2d 2d 72 61 6d |eap. The| in--ram|
|00001150| 20 5c 76 65 72 62 2b 76 | 64 6f 75 62 2b 0d 0a 63 | \verb+v|doub+..c|
|00001160| 6f 75 6e 74 73 20 74 68 | 65 20 6e 75 6d 62 65 72 |ounts th|e number|
|00001170| 20 6f 66 20 72 65 66 65 | 72 65 6e 63 65 73 20 74 | of refe|rences t|
|00001180| 6f 20 74 68 65 20 76 65 | 63 74 6f 72 2e 20 54 68 |o the ve|ctor. Th|
|00001190| 65 20 76 65 63 74 6f 72 | 20 69 73 20 6e 6f 74 0d |e vector| is not.|
|000011a0| 0a 66 72 65 65 64 20 75 | 6e 74 69 6c 20 74 68 65 |.freed u|ntil the|
|000011b0| 20 6e 75 6d 62 65 72 20 | 6f 66 20 72 65 66 65 72 | number |of refer|
|000011c0| 65 6e 63 65 73 20 69 73 | 0d 0a 7a 65 72 6f 2e 5c |ences is|..zero.\|
|000011d0| 69 6e 64 65 78 7b 56 4d | 61 74 72 69 78 21 49 4e |index{VM|atrix!IN|
|000011e0| 2d 52 41 4d 20 76 64 6f | 75 62 7d 0d 0a 0d 0a 0d |-RAM vdo|ub}.....|
|000011f0| 0a 5c 73 65 63 74 69 6f | 6e 7b 50 72 6f 74 65 63 |.\sectio|n{Protec|
|00001200| 74 65 64 20 50 61 72 74 | 73 20 6f 66 20 56 4d 61 |ted Part|s of VMa|
|00001210| 74 72 69 78 7d 0d 0a 54 | 68 65 20 70 72 6f 74 65 |trix}..T|he prote|
|00001220| 63 74 65 64 20 70 61 72 | 74 20 6f 66 20 56 4d 61 |cted par|t of VMa|
|00001230| 74 72 69 78 20 6d 75 73 | 74 20 62 65 20 61 63 63 |trix mus|t be acc|
|00001240| 65 73 73 69 62 6c 65 20 | 74 6f 20 74 68 65 0d 0a |essible |to the..|
|00001250| 6d 61 74 72 69 78 20 73 | 74 61 63 6b 2e 20 54 68 |matrix s|tack. Th|
|00001260| 65 20 73 69 67 6e 61 74 | 75 72 65 20 66 75 6e 63 |e signat|ure func|
|00001270| 74 69 6f 6e 73 20 61 73 | 20 69 6e 20 74 68 65 20 |tions as| in the |
|00001280| 76 6d 6d 20 61 6e 64 0d | 0a 76 64 6f 75 62 2e 20 |vmm and.|.vdoub. |
|00001290| 49 74 20 70 72 6f 76 69 | 64 65 73 20 61 6e 20 69 |It provi|des an i|
|000012a0| 6e 64 69 63 61 74 69 6f | 6e 20 6f 66 20 68 6f 77 |ndicatio|n of how|
|000012b0| 20 63 6f 72 72 75 70 74 | 20 6f 72 20 61 63 74 69 | corrupt| or acti|
|000012c0| 76 65 0d 0a 74 68 65 20 | 6d 61 74 72 69 78 20 68 |ve..the |matrix h|
|000012d0| 61 73 20 62 65 63 6f 6d | 65 2e 0d 0a 0d 0a 54 68 |as becom|e.....Th|
|000012e0| 65 20 66 75 6e 63 74 69 | 6f 6e 20 6d 69 6e 64 65 |e functi|on minde|
|000012f0| 78 28 20 69 6e 74 20 69 | 2c 20 69 6e 74 20 6a 29 |x( int i|, int j)|
|00001300| 5c 69 6e 64 65 78 7b 56 | 4d 61 74 72 69 78 21 6d |\index{V|Matrix!m|
|00001310| 69 6e 64 65 78 28 29 7d | 0d 0a 63 61 6c 63 75 6c |index()}|..calcul|
|00001320| 61 74 65 73 20 61 20 76 | 64 6f 75 62 20 76 65 63 |ates a v|doub vec|
|00001330| 74 6f 72 20 69 6e 64 65 | 78 2e 5c 66 6f 6f 74 6e |tor inde|x.\footn|
|00001340| 6f 74 65 7b 20 49 74 20 | 61 70 70 65 61 72 73 20 |ote{ It |appears |
|00001350| 61 20 62 69 74 0d 0a 68 | 65 61 76 79 20 68 61 6e |a bit..h|eavy han|
|00001360| 64 65 64 20 77 69 74 68 | 20 61 6c 6c 20 6f 66 20 |ded with| all of |
|00001370| 74 68 65 20 63 61 73 74 | 73 20 74 6f 20 6c 6f 6e |the cast|s to lon|
|00001380| 67 20 69 6e 74 73 2c 20 | 62 75 74 20 74 68 65 72 |g ints, |but ther|
|00001390| 65 0d 0a 77 65 72 65 20 | 73 6f 6d 65 20 70 72 6f |e..were |some pro|
|000013a0| 62 6c 65 6d 73 20 6f 66 | 20 69 6d 70 72 6f 70 65 |blems of| imprope|
|000013b0| 72 20 74 79 70 65 20 70 | 72 6f 6d 6f 74 69 6f 6e |r type p|romotion|
|000013c0| 20 65 6e 63 6f 75 6e 74 | 65 72 65 64 0d 0a 64 75 | encount|ered..du|
|000013d0| 72 69 6e 67 20 64 65 76 | 65 6c 6f 70 6d 65 6e 74 |ring dev|elopment|
|000013e0| 2e 7d 20 53 74 72 69 70 | 70 65 64 20 6f 66 20 74 |.} Strip|ped of t|
|000013f0| 68 65 20 63 61 73 74 73 | 2c 20 74 68 65 20 66 75 |he casts|, the fu|
|00001400| 6e 63 74 69 6f 6e 20 69 | 73 0d 0a 73 69 6d 70 6c |nction i|s..simpl|
|00001410| 79 20 5c 76 65 72 62 23 | 20 28 69 2d 31 29 2a 63 |y \verb#| (i-1)*c|
|00001420| 20 2b 20 28 6a 2d 31 29 | 20 23 2c 20 77 68 65 72 | + (j-1)| #, wher|
|00001430| 65 20 69 20 61 6e 64 20 | 6a 20 61 72 65 20 6d 61 |e i and |j are ma|
|00001440| 74 72 69 78 0d 0a 69 6e | 64 69 63 65 73 2c 20 61 |trix..in|dices, a|
|00001450| 6e 64 20 63 20 69 73 20 | 74 68 65 20 6e 75 6d 62 |nd c is |the numb|
|00001460| 65 72 20 6f 66 20 63 6f | 6c 75 6d 6e 73 20 6f 66 |er of co|lumns of|
|00001470| 20 74 68 65 20 6d 61 74 | 72 69 78 2e 0d 0a 4d 61 | the mat|rix...Ma|
|00001480| 74 72 69 63 65 73 20 61 | 72 65 20 69 6e 64 65 78 |trices a|re index|
|00001490| 65 64 20 66 72 6f 6d 20 | 31 20 74 6f 20 72 2c 20 |ed from |1 to r, |
|000014a0| 61 6e 64 20 31 20 74 6f | 20 63 2c 20 73 6f 20 74 |and 1 to| c, so t|
|000014b0| 68 65 72 65 20 61 72 65 | 0d 0a 72 2a 63 20 65 6c |here are|..r*c el|
|000014c0| 65 6d 65 6e 74 73 20 69 | 6e 20 74 68 65 20 63 6f |ements i|n the co|
|000014d0| 72 72 65 73 70 6f 6e 64 | 69 6e 67 20 76 64 6f 75 |rrespond|ing vdou|
|000014e0| 62 2e 20 48 6f 77 65 76 | 65 72 20 74 68 65 20 76 |b. Howev|er the v|
|000014f0| 64 6f 75 62 0d 0a 69 6e | 64 69 63 65 73 20 72 61 |doub..in|dices ra|
|00001500| 6e 67 65 20 66 72 6f 6d | 20 30 20 74 6f 20 72 2a |nge from| 0 to r*|
|00001510| 63 20 2d 20 31 2c 20 73 | 6f 20 74 68 65 20 69 2d |c - 1, s|o the i-|
|00001520| 31 20 61 6e 64 20 6a 2d | 31 20 66 6f 72 63 65 0d |1 and j-|1 force.|
|00001530| 0a 74 68 65 20 6d 69 6e | 69 6d 75 6d 20 6d 61 74 |.the min|imum mat|
|00001540| 72 69 78 20 69 6e 64 69 | 63 65 73 20 74 6f 20 62 |rix indi|ces to b|
|00001550| 65 20 31 2e 20 54 68 69 | 73 20 63 61 6c 63 75 6c |e 1. Thi|s calcul|
|00001560| 61 74 69 6f 6e 20 66 6f | 72 63 65 73 0d 0a 74 68 |ation fo|rces..th|
|00001570| 65 20 6d 61 74 72 69 78 | 20 74 6f 20 62 65 20 69 |e matrix| to be i|
|00001580| 6e 20 72 6f 77 20 6d 61 | 6a 6f 72 20 6f 72 64 65 |n row ma|jor orde|
|00001590| 72 2e 20 54 68 65 0d 0a | 63 75 72 76 65 63 69 6e |r. The..|curvecin|
|000015a0| 64 5c 69 6e 64 65 78 7b | 56 4d 61 74 72 69 78 21 |d\index{|VMatrix!|
|000015b0| 63 75 72 76 65 63 69 6e | 64 7d 20 69 73 20 61 20 |curvecin|d} is a |
|000015c0| 6c 6f 6e 67 20 69 6e 74 | 65 67 65 72 0d 0a 63 6f |long int|eger..co|
|000015d0| 6e 74 61 69 6e 69 6e 67 | 20 74 68 65 20 76 64 6f |ntaining| the vdo|
|000015e0| 75 62 20 69 6e 64 65 78 | 20 6f 66 20 74 68 65 20 |ub index| of the |
|000015f0| 63 75 72 72 65 6e 74 20 | 6d 61 74 72 69 78 20 65 |current |matrix e|
|00001600| 6c 65 6d 65 6e 74 2e 0d | 0a 0d 0a 54 68 65 20 6e |lement..|...The n|
|00001610| 61 6d 65 5c 69 6e 64 65 | 78 7b 56 4d 61 74 72 69 |ame\inde|x{VMatri|
|00001620| 78 21 6e 61 6d 65 7d 20 | 69 73 20 61 20 73 74 72 |x!name} |is a str|
|00001630| 69 6e 67 20 74 79 70 65 | 20 77 68 69 63 68 20 63 |ing type| which c|
|00001640| 61 6e 20 62 65 0d 0a 6d | 61 6e 69 70 75 6c 61 74 |an be..m|anipulat|
|00001650| 65 64 20 69 6e 20 74 68 | 65 20 6d 61 74 72 69 78 |ed in th|e matrix|
|00001660| 20 66 75 6e 63 74 69 6f | 6e 73 2e 20 54 68 65 20 | functio|ns. The |
|00001670| 66 75 6e 63 74 69 6f 6e | 73 20 61 72 65 0d 0a 66 |function|s are..f|
|00001680| 6f 75 6e 64 20 69 6e 20 | 74 68 65 20 70 75 62 6c |ound in |the publ|
|00001690| 69 63 20 70 61 72 74 2c | 20 62 75 74 20 61 72 65 |ic part,| but are|
|000016a0| 20 4e 61 6d 65 69 74 28 | 29 2c 20 47 65 74 6e 61 | Nameit(|), Getna|
|000016b0| 6d 65 28 29 2c 0d 0a 53 | 68 6f 77 6e 61 6d 65 28 |me(),..S|howname(|
|000016c0| 29 2c 20 61 6e 64 20 53 | 74 72 69 6e 67 41 64 64 |), and S|tringAdd|
|000016d0| 72 65 73 73 28 29 2e 0d | 0a 0d 0a 54 68 65 20 6e |ress()..|...The n|
|000016e0| 65 78 74 20 74 68 72 65 | 65 20 66 75 6e 63 74 69 |ext thre|e functi|
|000016f0| 6f 6e 73 20 63 6f 6e 74 | 72 6f 6c 20 74 68 65 20 |ons cont|rol the |
|00001700| 61 6c 6c 6f 63 61 74 69 | 6f 6e 20 6f 66 20 74 68 |allocati|on of th|
|00001710| 65 0d 0a 76 64 6f 75 62 | 20 76 65 63 74 6f 72 73 |e..vdoub| vectors|
|00001720| 2e 20 52 65 70 6c 61 63 | 65 28 29 5c 69 6e 64 65 |. Replac|e()\inde|
|00001730| 78 7b 56 4d 61 74 72 69 | 78 21 52 65 70 6c 61 63 |x{VMatri|x!Replac|
|00001740| 65 28 29 7d 20 63 61 6c | 6c 73 0d 0a 50 75 72 67 |e()} cal|ls..Purg|
|00001750| 65 56 65 63 74 6f 72 73 | 28 29 5c 69 6e 64 65 78 |eVectors|()\index|
|00001760| 7b 56 4d 61 74 72 69 78 | 21 50 75 72 67 65 56 65 |{VMatrix|!PurgeVe|
|00001770| 63 74 6f 72 73 28 29 7d | 20 61 6e 64 0d 0a 53 65 |ctors()}| and..Se|
|00001780| 74 75 70 56 65 63 74 6f | 72 73 28 29 5c 69 6e 64 |tupVecto|rs()\ind|
|00001790| 65 78 7b 56 4d 61 74 72 | 69 78 21 53 65 74 75 70 |ex{VMatr|ix!Setup|
|000017a0| 56 65 63 74 6f 72 73 28 | 29 7d 20 69 66 20 74 68 |Vectors(|)} if th|
|000017b0| 65 20 56 4d 61 74 72 69 | 78 0d 0a 62 65 69 6e 67 |e VMatri|x..being|
|000017c0| 20 72 65 70 6c 61 63 65 | 64 20 68 61 73 20 64 69 | replace|d has di|
|000017d0| 66 66 65 72 65 6e 74 20 | 64 69 6d 65 6e 73 69 6f |fferent |dimensio|
|000017e0| 6e 73 20 74 68 61 6e 20 | 74 68 65 20 72 65 70 6c |ns than |the repl|
|000017f0| 61 63 69 6e 67 0d 0a 56 | 4d 61 74 72 69 78 2e 20 |acing..V|Matrix. |
|00001800| 52 65 70 6c 61 63 65 28 | 29 20 69 73 20 63 61 6c |Replace(|) is cal|
|00001810| 6c 65 64 20 62 79 20 74 | 68 65 0d 0a 6f 70 65 72 |led by t|he..oper|
|00001820| 61 74 6f 72 3d 28 29 5c | 69 6e 64 65 78 7b 56 4d |ator=()\|index{VM|
|00001830| 61 74 72 69 78 21 61 73 | 73 69 67 6e 6d 65 6e 74 |atrix!as|signment|
|00001840| 7d 2e 20 20 50 75 72 67 | 65 56 65 63 74 6f 72 73 |}. Purg|eVectors|
|00001850| 28 29 0d 0a 63 61 6c 6c | 73 20 76 66 72 65 65 28 |()..call|s vfree(|
|00001860| 29 20 74 6f 20 66 72 65 | 65 20 74 68 65 20 68 64 |) to fre|e the hd|
|00001870| 72 20 69 6e 20 74 68 65 | 20 70 72 6f 74 65 63 74 |r in the| protect|
|00001880| 65 64 20 70 61 72 74 20 | 6f 66 0d 0a 76 64 6f 75 |ed part |of..vdou|
|00001890| 62 2e 20 53 65 74 75 70 | 56 65 63 74 6f 72 73 28 |b. Setup|Vectors(|
|000018a0| 29 20 63 61 6c 6c 73 20 | 76 6d 61 6c 6c 6f 63 28 |) calls |vmalloc(|
|000018b0| 29 20 74 6f 20 63 72 65 | 61 74 65 20 61 20 6e 65 |) to cre|ate a ne|
|000018c0| 77 20 68 64 72 0d 0a 66 | 6f 72 20 76 64 6f 75 62 |w hdr..f|or vdoub|
|000018d0| 2e 5c 66 6f 6f 74 6e 6f | 74 65 7b 20 54 68 69 73 |.\footno|te{ This|
|000018e0| 20 61 62 69 6c 69 74 79 | 20 74 6f 20 6f 70 65 72 | ability| to oper|
|000018f0| 61 74 65 20 6f 6e 20 74 | 68 65 20 68 64 72 20 6f |ate on t|he hdr o|
|00001900| 66 0d 0a 76 64 6f 75 62 | 20 63 6c 61 72 69 66 69 |f..vdoub| clarifi|
|00001910| 65 64 20 74 68 65 20 6d | 65 61 6e 69 6e 67 20 6f |ed the m|eaning o|
|00001920| 66 20 69 6e 68 65 72 69 | 74 61 6e 63 65 20 66 6f |f inheri|tance fo|
|00001930| 72 20 6d 65 20 73 69 6e | 63 65 20 61 0d 0a 56 4d |r me sin|ce a..VM|
|00001940| 61 74 72 69 78 20 69 73 | 20 72 65 61 6c 6c 79 20 |atrix is| really |
|00001950| 6a 75 73 74 20 61 20 76 | 69 72 74 75 61 6c 20 76 |just a v|irtual v|
|00001960| 65 63 74 6f 72 20 77 69 | 74 68 20 73 6f 6d 65 20 |ector wi|th some |
|00001970| 65 78 74 72 61 0d 0a 66 | 75 6e 63 74 69 6f 6e 61 |extra..f|unctiona|
|00001980| 6c 69 74 79 2e 20 49 74 | 20 61 6c 73 6f 20 73 68 |lity. It| also sh|
|00001990| 6f 77 73 20 77 68 79 20 | 74 68 65 20 68 64 72 20 |ows why |the hdr |
|000019a0| 6d 75 73 74 20 62 65 20 | 70 72 6f 74 65 63 74 65 |must be |protecte|
|000019b0| 64 0d 0a 72 61 74 68 65 | 72 20 74 68 61 6e 20 70 |d..rathe|r than p|
|000019c0| 72 69 76 61 74 65 20 69 | 6e 20 76 64 6f 75 62 2e |rivate i|n vdoub.|
|000019d0| 7d 0d 0a 0d 0a 46 6f 72 | 20 74 68 65 20 69 6e 2d |}....For| the in-|
|000019e0| 72 61 6d 20 76 65 72 73 | 69 6f 6e 2c 20 53 65 74 |ram vers|ion, Set|
|000019f0| 75 70 56 65 63 74 6f 72 | 73 28 29 20 61 6c 6c 6f |upVector|s() allo|
|00001a00| 63 61 74 65 73 20 72 2a | 63 2b 31 20 65 6c 65 6d |cates r*|c+1 elem|
|00001a10| 65 6e 74 73 0d 0a 6f 6e | 20 74 68 65 20 68 65 61 |ents..on| the hea|
|00001a20| 70 20 75 73 69 6e 67 20 | 63 61 6c 6c 6f 63 28 29 |p using |calloc()|
|00001a30| 2e 20 54 68 65 20 66 69 | 72 73 74 20 65 6c 65 6d |. The fi|rst elem|
|00001a40| 65 6e 74 20 69 73 20 73 | 65 74 20 74 6f 0d 0a 53 |ent is s|et to..S|
|00001a50| 49 47 4e 41 54 55 52 45 | 2c 20 74 68 65 6e 20 74 |IGNATURE|, then t|
|00001a60| 68 65 20 62 61 73 65 20 | 69 73 20 73 68 69 66 74 |he base |is shift|
|00001a70| 65 64 20 62 79 20 31 2e | 20 54 68 75 73 2c 20 6d |ed by 1.| Thus, m|
|00001a80| 5b 2d 31 5d 20 69 73 20 | 61 20 63 68 65 63 6b 0d |[-1] is |a check.|
|00001a90| 0a 76 61 6c 75 65 2e 20 | 49 66 20 74 68 65 20 76 |.value. |If the v|
|00001aa0| 61 6c 75 65 20 69 73 20 | 6e 6f 74 20 65 71 75 61 |alue is |not equa|
|00001ab0| 6c 20 74 6f 20 53 49 47 | 4e 41 54 55 52 45 2c 20 |l to SIG|NATURE, |
|00001ac0| 74 68 65 6e 20 74 68 65 | 20 6d 61 74 72 69 78 0d |then the| matrix.|
|00001ad0| 0a 68 61 73 20 62 65 65 | 6e 20 64 65 6c 65 74 65 |.has bee|n delete|
|00001ae0| 64 20 6f 72 20 63 6c 6f | 62 62 65 72 65 64 2e 0d |d or clo|bbered..|
|00001af0| 0a 0d 0a 54 68 65 20 66 | 75 6e 63 74 69 6f 6e 20 |...The f|unction |
|00001b00| 5c 76 65 72 62 2b 4e 65 | 77 52 65 66 65 72 65 6e |\verb+Ne|wReferen|
|00001b10| 63 65 28 29 2b 0d 0a 5c | 69 6e 64 65 78 7b 56 4d |ce()+..\|index{VM|
|00001b20| 61 74 72 69 78 21 4e 65 | 77 52 65 66 65 72 65 6e |atrix!Ne|wReferen|
|00001b30| 63 65 28 29 7d 20 69 73 | 20 75 73 65 64 20 62 79 |ce()} is| used by|
|00001b40| 20 74 68 65 20 6d 61 74 | 72 69 78 20 73 74 61 63 | the mat|rix stac|
|00001b50| 6b 20 74 6f 0d 0a 73 65 | 74 20 75 70 20 61 20 72 |k to..se|t up a r|
|00001b60| 65 66 65 72 65 6e 63 65 | 20 74 6f 20 61 20 62 61 |eference| to a ba|
|00001b70| 73 65 20 76 65 63 74 6f | 72 20 69 6e 73 74 65 61 |se vecto|r instea|
|00001b80| 64 20 6f 66 20 61 20 63 | 6f 70 79 2e 20 49 74 20 |d of a c|opy. It |
|00001b90| 69 73 0d 0a 70 61 72 74 | 20 6f 66 20 74 68 65 20 |is..part| of the |
|00001ba0| 64 65 65 70 20 63 6f 70 | 79 20 74 65 63 68 6e 69 |deep cop|y techni|
|00001bb0| 71 75 65 20 75 73 65 64 | 20 62 79 20 70 75 73 68 |que used| by push|
|00001bc0| 2e 0d 0a 0d 0a 5c 73 65 | 63 74 69 6f 6e 7b 54 68 |.....\se|ction{Th|
|00001bd0| 65 20 50 75 62 6c 69 63 | 20 50 61 72 74 20 6f 66 |e Public| Part of|
|00001be0| 20 56 4d 61 74 72 69 78 | 7d 0d 0a 0d 0a 5c 73 75 | VMatrix|}....\su|
|00001bf0| 62 73 65 63 74 69 6f 6e | 7b 45 72 72 6f 72 20 44 |bsection|{Error D|
|00001c00| 65 74 65 63 74 69 6f 6e | 7d 0d 0a 0d 0a 44 6f 6e |etection|}....Don|
|00001c10| 27 74 20 6c 65 74 20 4f | 4f 50 20 66 6f 6f 6c 20 |'t let O|OP fool |
|00001c20| 79 6f 75 2e 20 49 74 27 | 73 20 70 6f 69 6e 74 65 |you. It'|s pointe|
|00001c30| 72 20 7b 5c 65 6d 20 69 | 6e 74 65 6e 73 69 76 65 |r {\em i|ntensive|
|00001c40| 7d 2e 20 54 68 65 0d 0a | 61 70 70 72 6f 61 63 68 |}. The..|approach|
|00001c50| 20 74 61 6b 65 6e 20 68 | 65 72 65 20 69 73 20 74 | taken h|ere is t|
|00001c60| 6f 20 73 74 6f 70 20 74 | 68 65 20 70 72 6f 67 72 |o stop t|he progr|
|00001c70| 61 6d 20 61 74 20 74 68 | 65 20 73 6c 69 67 68 74 |am at th|e slight|
|00001c80| 65 73 74 0d 0a 70 72 6f | 62 6c 65 6d 2e 20 54 68 |est..pro|blem. Th|
|00001c90| 69 73 20 63 6f 6e 73 65 | 72 76 61 74 69 76 65 20 |is conse|rvative |
|00001ca0| 61 70 70 72 6f 61 63 68 | 20 72 65 73 75 6c 74 73 |approach| results|
|00001cb0| 20 66 72 6f 6d 20 73 65 | 76 65 72 61 6c 0d 0a 79 | from se|veral..y|
|00001cc0| 65 61 72 73 20 65 78 70 | 65 72 69 65 6e 63 65 20 |ears exp|erience |
|00001cd0| 77 69 74 68 20 72 6f 67 | 75 65 20 73 74 72 69 6e |with rog|ue strin|
|00001ce0| 67 73 2c 20 64 61 6e 67 | 6c 69 6e 67 20 70 6f 69 |gs, dang|ling poi|
|00001cf0| 6e 74 65 72 73 20 74 6f | 0d 0a 66 72 65 65 64 20 |nters to|..freed |
|00001d00| 73 70 61 63 65 2c 20 61 | 6e 64 20 6a 75 6d 70 69 |space, a|nd jumpi|
|00001d10| 6e 67 20 74 6f 20 65 78 | 65 63 75 74 69 6f 6e 20 |ng to ex|ecution |
|00001d20| 6f 66 20 74 68 65 20 68 | 65 61 70 20 62 65 63 61 |of the h|eap beca|
|00001d30| 75 73 65 20 61 0d 0a 73 | 74 72 61 79 20 62 69 74 |use a..s|tray bit|
|00001d40| 20 6f 66 20 64 61 74 61 | 20 6c 61 6e 64 65 64 20 | of data| landed |
|00001d50| 69 6e 20 6d 79 20 69 6e | 74 65 72 72 75 70 74 20 |in my in|terrupt |
|00001d60| 76 65 63 74 6f 72 20 74 | 61 62 6c 65 2e 20 54 68 |vector t|able. Th|
|00001d70| 65 73 65 0d 0a 61 72 65 | 20 73 6f 6d 65 20 6f 66 |ese..are| some of|
|00001d80| 20 74 68 65 20 6c 65 73 | 73 20 62 65 6e 69 67 6e | the les|s benign|
|00001d90| 20 74 68 69 6e 67 73 20 | 74 68 61 74 20 63 61 6e | things |that can|
|00001da0| 20 68 61 70 70 65 6e 20 | 77 68 65 6e 0d 0a 75 73 | happen |when..us|
|00001db0| 69 6e 67 20 70 6f 69 6e | 74 65 72 73 2e 0d 0a 0d |ing poin|ters....|
|00001dc0| 0a 54 77 6f 20 65 72 72 | 6f 72 20 64 65 74 65 63 |.Two err|or detec|
|00001dd0| 74 69 6f 6e 20 72 6f 75 | 74 69 6e 65 73 20 61 72 |tion rou|tines ar|
|00001de0| 65 20 70 72 6f 76 69 64 | 65 64 20 66 6f 72 20 61 |e provid|ed for a|
|00001df0| 20 67 72 61 63 65 66 75 | 6c 0d 0a 65 78 69 74 20 | gracefu|l..exit |
|00001e00| 66 72 6f 6d 20 74 68 65 | 20 70 72 6f 67 72 61 6d |from the| program|
|00001e10| 2e 20 54 68 65 73 65 20 | 72 6f 75 74 69 6e 65 73 |. These |routines|
|00001e20| 20 70 72 69 6e 74 20 61 | 20 6d 65 73 73 61 67 65 | print a| message|
|00001e30| 20 6f 66 0d 0a 77 68 69 | 63 68 20 72 6f 75 74 69 | of..whi|ch routi|
|00001e40| 6e 65 20 77 61 73 20 61 | 63 74 69 76 65 20 77 68 |ne was a|ctive wh|
|00001e50| 65 6e 20 74 68 65 20 70 | 72 6f 67 72 61 6d 20 66 |en the p|rogram f|
|00001e60| 61 69 6c 65 64 2e 0d 0a | 4e 72 65 72 72 6f 72 28 |ailed...|Nrerror(|
|00001e70| 29 5c 69 6e 64 65 78 7b | 56 4d 61 74 72 69 78 21 |)\index{|VMatrix!|
|00001e80| 4e 72 65 72 72 6f 72 7d | 20 70 72 69 6e 74 73 20 |Nrerror}| prints |
|00001e90| 61 6e 20 65 72 72 6f 72 | 20 6d 65 73 73 61 67 65 |an error| message|
|00001ea0| 0d 0a 61 6e 64 20 65 78 | 69 74 73 20 74 6f 20 74 |..and ex|its to t|
|00001eb0| 68 65 20 73 79 73 74 65 | 6d 20 77 69 74 68 20 65 |he syste|m with e|
|00001ec0| 72 72 6f 72 20 63 6f 64 | 65 20 31 2e 20 4e 6f 74 |rror cod|e 1. Not|
|00001ed0| 65 20 74 68 61 74 20 69 | 74 20 69 73 0d 0a 64 65 |e that i|t is..de|
|00001ee0| 63 6c 61 72 65 64 20 74 | 6f 20 72 65 74 75 72 6e |clared t|o return|
|00001ef0| 20 61 20 64 6f 75 62 6c | 65 2e 20 54 68 69 73 20 | a doubl|e. This |
|00001f00| 69 73 20 73 6f 20 4e 72 | 65 72 72 6f 72 28 29 20 |is so Nr|error() |
|00001f10| 63 61 6e 20 62 65 0d 0a | 70 6c 61 63 65 64 20 69 |can be..|placed i|
|00001f20| 6e 20 74 68 65 20 74 65 | 72 6e 61 72 79 20 6f 70 |n the te|rnary op|
|00001f30| 65 72 61 74 6f 72 20 27 | 3f 3a 27 20 77 68 65 72 |erator '|?:' wher|
|00001f40| 65 20 61 20 64 6f 75 62 | 6c 65 20 69 73 20 74 6f |e a doub|le is to|
|00001f50| 20 62 65 0d 0a 72 65 74 | 75 72 6e 65 64 2e 20 46 | be..ret|urned. F|
|00001f60| 6f 72 20 69 6e 73 74 61 | 6e 63 65 2c 20 73 75 70 |or insta|nce, sup|
|00001f70| 70 6f 73 65 20 78 3d 20 | 2d 31 2e 30 2c 20 74 68 |pose x= |-1.0, th|
|00001f80| 65 6e 20 74 68 65 20 73 | 74 61 74 65 6d 65 6e 74 |en the s|tatement|
|00001f90| 20 0d 0a 5c 62 65 67 69 | 6e 7b 76 65 72 62 61 74 | ..\begi|n{verbat|
|00001fa0| 69 6d 7d 0d 0a 20 20 20 | 64 6f 75 62 6c 65 20 79 |im}.. |double y|
|00001fb0| 20 3d 20 28 20 78 3e 30 | 20 29 20 3f 20 6c 6f 67 | = ( x>0| ) ? log|
|00001fc0| 28 78 29 20 3a 20 4e 72 | 65 72 72 6f 72 28 22 4c |(x) : Nr|error("L|
|00001fd0| 4f 47 3a 20 6e 65 67 61 | 74 69 76 65 20 76 61 6c |OG: nega|tive val|
|00001fe0| 75 65 22 29 3b 0d 0a 5c | 65 6e 64 7b 76 65 72 62 |ue");..\|end{verb|
|00001ff0| 61 74 69 6d 7d 0d 0a 77 | 69 6c 6c 20 63 6f 6d 70 |atim}..w|ill comp|
|00002000| 69 6c 65 20 63 6f 72 72 | 65 63 74 6c 79 20 73 69 |ile corr|ectly si|
|00002010| 6e 63 65 20 74 68 65 20 | 63 6f 6d 70 69 6c 65 72 |nce the |compiler|
|00002020| 20 74 68 69 6e 6b 73 20 | 4e 72 65 72 72 6f 72 28 | thinks |Nrerror(|
|00002030| 29 0d 0a 77 69 6c 6c 20 | 72 65 74 75 72 6e 20 61 |)..will |return a|
|00002040| 20 64 6f 75 62 6c 65 2e | 20 54 68 65 20 63 6f 6d | double.| The com|
|00002050| 70 69 6c 65 72 20 64 6f | 65 73 20 6e 6f 74 20 6b |piler do|es not k|
|00002060| 6e 6f 77 20 74 68 61 74 | 20 74 68 65 0d 0a 70 72 |now that| the..pr|
|00002070| 6f 67 72 61 6d 20 77 69 | 6c 6c 20 65 78 69 74 20 |ogram wi|ll exit |
|00002080| 62 65 66 6f 72 65 20 74 | 68 65 20 72 65 74 75 72 |before t|he retur|
|00002090| 6e 2e 20 4e 72 65 72 72 | 6f 72 28 29 20 70 72 6f |n. Nrerr|or() pro|
|000020a0| 76 69 64 65 73 20 61 0d | 0a 73 69 6d 69 6c 61 72 |vides a.|.similar|
|000020b0| 20 66 75 6e 63 74 69 6f | 6e 20 69 6e 20 50 72 65 | functio|n in Pre|
|000020c0| 73 73 5c 63 69 74 65 7b | 50 72 3a 6e 72 63 7d 20 |ss\cite{|Pr:nrc} |
|000020d0| 77 68 69 63 68 20 69 73 | 20 61 6e 0d 0a 65 78 63 |which is| an..exc|
|000020e0| 65 6c 6c 65 6e 74 20 73 | 6f 75 72 63 65 20 66 6f |ellent s|ource fo|
|000020f0| 72 20 63 6f 64 65 20 74 | 6f 20 74 72 61 6e 73 6c |r code t|o transl|
|00002100| 61 74 65 20 74 6f 20 56 | 4d 61 74 72 69 78 0d 0a |ate to V|Matrix..|
|00002110| 66 75 6e 63 74 69 6f 6e | 73 2e 5c 66 6f 6f 74 6e |function|s.\footn|
|00002120| 6f 74 65 7b 49 66 20 79 | 6f 75 20 66 6f 72 63 65 |ote{If y|ou force|
|00002130| 20 61 20 7a 65 72 6f 20 | 64 69 76 69 73 69 6f 6e | a zero |division|
|00002140| 20 69 6e 20 74 68 69 73 | 0d 0a 72 6f 75 74 69 6e | in this|..routin|
|00002150| 65 2c 20 56 41 58 20 43 | 43 20 77 69 6c 6c 20 63 |e, VAX C|C will c|
|00002160| 61 75 73 65 20 61 20 70 | 72 69 6e 74 20 6f 66 20 |ause a p|rint of |
|00002170| 74 68 65 20 66 75 6e 63 | 74 69 6f 6e 20 63 61 6c |the func|tion cal|
|00002180| 6c 0d 0a 73 65 71 75 65 | 6e 63 65 20 74 6f 20 74 |l..seque|nce to t|
|00002190| 68 65 20 65 72 72 6f 72 | 20 6f 75 74 70 75 74 20 |he error| output |
|000021a0| 73 74 72 65 61 6d 7d 0d | 0a 0d 0a 54 68 65 72 65 |stream}.|...There|
|000021b0| 20 61 72 65 20 74 77 6f | 20 66 75 6e 63 74 69 6f | are two| functio|
|000021c0| 6e 73 20 63 61 6c 6c 65 | 64 0d 0a 47 61 72 62 61 |ns calle|d..Garba|
|000021d0| 67 65 28 29 5c 69 6e 64 | 65 78 7b 56 4d 61 74 72 |ge()\ind|ex{VMatr|
|000021e0| 69 78 21 47 61 72 62 61 | 67 65 28 29 7d 2e 20 54 |ix!Garba|ge()}. T|
|000021f0| 68 65 79 20 74 65 73 74 | 20 74 68 65 20 69 6e 74 |hey test| the int|
|00002200| 65 67 72 69 74 79 0d 0a | 6f 66 20 74 68 65 20 6d |egrity..|of the m|
|00002210| 61 74 72 69 78 20 61 72 | 67 75 6d 65 6e 74 73 20 |atrix ar|guments |
|00002220| 69 6e 20 66 75 6e 63 74 | 69 6f 6e 20 63 61 6c 6c |in funct|ion call|
|00002230| 73 2e 20 49 74 20 70 72 | 69 6e 74 73 20 74 68 65 |s. It pr|ints the|
|00002240| 0d 0a 72 6f 75 74 69 6e | 65 20 77 68 65 72 65 20 |..routin|e where |
|00002250| 61 20 67 61 72 62 61 67 | 65 20 6d 61 74 72 69 78 |a garbag|e matrix|
|00002260| 20 77 61 73 20 66 6f 75 | 6e 64 2c 20 74 68 65 6e | was fou|nd, then|
|00002270| 20 63 61 6c 6c 73 0d 0a | 4e 72 65 72 72 6f 72 28 | calls..|Nrerror(|
|00002280| 29 2e 20 41 20 67 6f 6f | 64 20 65 78 61 6d 70 6c |). A goo|d exampl|
|00002290| 65 20 6f 66 20 74 68 69 | 73 20 66 75 6e 63 74 69 |e of thi|s functi|
|000022a0| 6f 6e 20 69 73 20 66 6f | 75 6e 64 20 69 6e 20 74 |on is fo|und in t|
|000022b0| 68 65 0d 0a 61 73 73 69 | 67 6e 6d 65 6e 74 20 66 |he..assi|gnment f|
|000022c0| 75 6e 63 74 69 6f 6e 20 | 66 6f 72 20 56 4d 61 74 |unction |for VMat|
|000022d0| 72 69 78 3a 0d 0a 5c 62 | 65 67 69 6e 7b 76 65 72 |rix:..\b|egin{ver|
|000022e0| 62 61 74 69 6d 7d 0d 0a | 76 6f 69 64 20 56 4d 61 |batim}..|void VMa|
|000022f0| 74 72 69 78 3a 3a 6f 70 | 65 72 61 74 6f 72 3d 20 |trix::op|erator= |
|00002300| 28 56 4d 61 74 72 69 78 | 20 26 52 4f 70 29 0d 0a |(VMatrix| &ROp)..|
|00002310| 7b 0d 0a 20 20 20 47 61 | 72 62 61 67 65 28 22 6f |{.. Ga|rbage("o|
|00002320| 70 65 72 61 74 6f 72 20 | 3d 22 29 3b 0d 0a 20 20 |perator |=");.. |
|00002330| 20 52 4f 70 2e 47 61 72 | 62 61 67 65 28 22 6f 70 | ROp.Gar|bage("op|
|00002340| 65 72 61 74 6f 72 20 3d | 22 29 3b 0d 0a 20 20 20 |erator =|");.. |
|00002350| 2e 0d 0a 20 20 20 2e 0d | 0a 20 20 20 2e 0d 0a 7d |... ..|. ...}|
|00002360| 0d 0a 5c 65 6e 64 7b 76 | 65 72 62 61 74 69 6d 7d |..\end{v|erbatim}|
|00002370| 0d 0a 46 69 72 73 74 20 | 74 68 65 20 6d 65 6d 62 |..First |the memb|
|00002380| 65 72 20 66 75 6e 63 74 | 69 6f 6e 20 6f 66 20 74 |er funct|ion of t|
|00002390| 68 65 20 56 4d 61 74 72 | 69 78 20 2a 74 68 69 73 |he VMatr|ix *this|
|000023a0| 20 69 73 20 63 61 6c 6c | 65 64 2e 0d 0a 4e 65 78 | is call|ed...Nex|
|000023b0| 74 20 74 68 65 20 52 4f | 70 20 6d 65 6d 62 65 72 |t the RO|p member|
|000023c0| 20 66 75 6e 63 74 69 6f | 6e 20 69 73 20 63 61 6c | functio|n is cal|
|000023d0| 6c 65 64 2e 20 54 68 65 | 20 73 69 67 6e 61 74 75 |led. The| signatu|
|000023e0| 72 65 20 69 73 0d 0a 63 | 68 65 63 6b 65 64 20 66 |re is..c|hecked f|
|000023f0| 6f 72 20 76 61 6c 69 64 | 69 74 79 2e 20 49 66 20 |or valid|ity. If |
|00002400| 69 74 20 69 73 20 77 72 | 6f 6e 67 2c 20 74 68 65 |it is wr|ong, the|
|00002410| 20 70 72 6f 67 72 61 6d | 20 73 74 6f 70 73 2e 0d | program| stops..|
|00002420| 0a 59 6f 75 20 73 68 6f | 75 6c 64 20 6d 61 6b 65 |.You sho|uld make|
|00002430| 20 61 20 68 61 62 69 74 | 20 6f 66 20 63 68 65 63 | a habit| of chec|
|00002440| 6b 69 6e 67 20 66 6f 72 | 20 69 6e 63 6f 6d 69 6e |king for| incomin|
|00002450| 67 20 6d 61 74 72 69 63 | 65 73 0d 0a 74 68 61 74 |g matric|es..that|
|00002460| 20 63 6f 75 6c 64 20 63 | 61 75 73 65 20 74 68 65 | could c|ause the|
|00002470| 20 70 72 6f 67 72 61 6d | 20 74 6f 20 62 6f 6d 62 | program| to bomb|
|00002480| 20 62 79 20 75 73 69 6e | 67 20 74 68 65 20 47 61 | by usin|g the Ga|
|00002490| 72 62 61 67 65 28 29 0d | 0a 66 75 6e 63 74 69 6f |rbage().|.functio|
|000024a0| 6e 73 2e 0d 0a 0d 0a 5c | 73 75 62 73 65 63 74 69 |ns.....\|subsecti|
|000024b0| 6f 6e 7b 49 6e 64 65 78 | 69 6e 67 20 61 6e 64 20 |on{Index|ing and |
|000024c0| 41 73 73 69 67 6e 69 6e | 67 20 45 6c 65 6d 65 6e |Assignin|g Elemen|
|000024d0| 74 73 7d 0d 0a 0d 0a 54 | 68 65 20 69 6e 64 65 78 |ts}....T|he index|
|000024e0| 69 6e 67 20 72 61 6e 67 | 65 20 69 73 20 70 72 65 |ing rang|e is pre|
|000024f0| 74 74 79 20 73 69 6d 70 | 6c 65 2e 20 4d 61 74 72 |tty simp|le. Matr|
|00002500| 69 78 20 65 6c 65 6d 65 | 6e 74 73 20 61 72 65 0d |ix eleme|nts are.|
|00002510| 0a 69 6e 64 65 78 65 64 | 20 66 72 6f 6d 20 31 20 |.indexed| from 1 |
|00002520| 74 6f 20 63 2c 20 61 6e | 64 20 66 72 6f 6d 20 31 |to c, an|d from 1|
|00002530| 20 74 6f 20 72 2e 20 54 | 68 65 72 65 20 61 72 65 | to r. T|here are|
|00002540| 20 73 6f 6d 65 0d 0a 74 | 72 61 64 65 6f 66 66 73 | some..t|radeoffs|
|00002550| 20 68 65 72 65 2e 20 49 | 20 63 6f 75 6c 64 20 6e | here. I| could n|
|00002560| 6f 74 20 66 69 67 75 72 | 65 20 6f 75 74 20 68 6f |ot figur|e out ho|
|00002570| 77 20 74 6f 20 6f 76 65 | 72 6c 6f 61 64 20 61 0d |w to ove|rload a.|
|00002580| 0a 64 6f 75 62 6c 65 20 | 62 72 61 63 6b 65 74 20 |.double |bracket |
|00002590| 6f 70 65 72 61 74 6f 72 | 2c 20 5b 5d 5b 5d 2c 20 |operator|, [][], |
|000025a0| 73 6f 20 49 20 72 65 73 | 6f 72 74 65 64 20 74 6f |so I res|orted to|
|000025b0| 20 61 0d 0a 66 75 6e 63 | 74 69 6f 6e 61 6c 20 61 | a..func|tional a|
|000025c0| 70 70 72 6f 61 63 68 20 | 74 6f 20 69 6e 64 65 78 |pproach |to index|
|000025d0| 69 6e 67 2e 20 54 77 6f | 20 69 6e 64 65 78 20 66 |ing. Two| index f|
|000025e0| 75 6e 63 74 69 6f 6e 73 | 20 77 65 72 65 0d 0a 63 |unctions| were..c|
|000025f0| 72 65 61 74 65 64 2c 20 | 6f 6e 65 20 66 6f 72 20 |reated, |one for |
|00002600| 65 61 63 68 20 73 69 64 | 65 20 6f 66 20 61 6e 20 |each sid|e of an |
|00002610| 65 71 75 61 6c 73 20 6f | 70 65 72 61 74 6f 72 2e |equals o|perator.|
|00002620| 20 54 68 65 0d 0a 6c 69 | 74 74 6c 65 20 6d 28 69 | The..li|ttle m(i|
|00002630| 2c 6a 29 20 72 65 74 75 | 72 6e 73 20 61 20 64 6f |,j) retu|rns a do|
|00002640| 75 62 6c 65 2e 20 54 68 | 65 20 62 69 67 20 4d 28 |uble. Th|e big M(|
|00002650| 69 2c 6a 29 20 72 65 74 | 75 72 6e 73 20 61 0d 0a |i,j) ret|urns a..|
|00002660| 72 65 66 65 72 65 6e 63 | 65 20 74 6f 20 61 20 56 |referenc|e to a V|
|00002670| 4d 61 74 72 69 78 2e 20 | 42 6f 74 68 20 66 75 6e |Matrix. |Both fun|
|00002680| 63 74 69 6f 6e 73 20 63 | 61 6c 6c 20 6d 69 6e 64 |ctions c|all mind|
|00002690| 65 78 28 29 20 61 6e 64 | 0d 0a 73 65 74 20 63 75 |ex() and|..set cu|
|000026a0| 72 76 65 63 69 6e 64 2e | 20 20 54 68 65 20 64 69 |rvecind.| The di|
|000026b0| 66 66 65 72 65 6e 63 65 | 20 62 65 74 77 65 65 6e |fference| between|
|000026c0| 20 74 68 65 20 74 77 6f | 20 6f 70 65 72 61 74 6f | the two| operato|
|000026d0| 72 73 20 69 73 0d 0a 74 | 68 61 74 20 6d 28 69 2c |rs is..t|hat m(i,|
|000026e0| 6a 29 20 63 61 6c 6c 73 | 20 74 68 65 20 76 64 6f |j) calls| the vdo|
|000026f0| 75 62 20 6d 65 6d 62 65 | 72 20 66 75 6e 63 74 69 |ub membe|r functi|
|00002700| 6f 6e 20 76 28 29 20 66 | 6f 72 0d 0a 72 65 74 75 |on v() f|or..retu|
|00002710| 72 6e 69 6e 67 20 61 20 | 6d 61 74 72 69 78 20 65 |rning a |matrix e|
|00002720| 6c 65 6d 65 6e 74 2e 20 | 54 68 65 20 66 75 6e 63 |lement. |The func|
|00002730| 74 69 6f 6e 20 4d 28 69 | 2c 6a 29 20 63 61 6c 6c |tion M(i|,j) call|
|00002740| 73 20 74 68 65 0d 0a 76 | 64 6f 75 62 20 62 72 61 |s the..v|doub bra|
|00002750| 63 6b 65 74 20 6f 70 65 | 72 61 74 6f 72 73 2e 20 |cket ope|rators. |
|00002760| 59 6f 75 20 63 61 6e 20 | 74 68 69 6e 6b 20 6f 66 |You can |think of|
|00002770| 0d 0a 4d 28 69 2c 6a 29 | 5c 69 6e 64 65 78 7b 56 |..M(i,j)|\index{V|
|00002780| 4d 61 74 72 69 78 21 4d | 28 29 7d 20 61 6e 64 20 |Matrix!M|()} and |
|00002790| 6d 28 69 2c 6a 29 5c 69 | 6e 64 65 78 7b 56 4d 61 |m(i,j)\i|ndex{VMa|
|000027a0| 74 72 69 78 21 6d 28 29 | 7d 20 61 73 0d 0a 73 75 |trix!m()|} as..su|
|000027b0| 72 72 6f 67 61 74 65 73 | 20 66 6f 72 20 76 64 6f |rrogates| for vdo|
|000027c0| 75 62 3a 3a 6f 70 65 72 | 61 74 6f 72 5b 5d 20 61 |ub::oper|ator[] a|
|000027d0| 6e 64 20 74 68 65 20 76 | 64 6f 75 62 20 66 75 6e |nd the v|doub fun|
|000027e0| 63 74 69 6f 6e 0d 0a 76 | 28 29 2e 0d 0a 0d 0a 54 |ction..v|().....T|
|000027f0| 6f 20 61 73 73 69 67 6e | 20 61 6e 20 65 6c 65 6d |o assign| an elem|
|00002800| 65 6e 74 20 74 6f 20 61 | 20 6d 61 74 72 69 78 2c |ent to a| matrix,|
|00002810| 20 75 73 65 20 73 74 61 | 74 65 6d 65 6e 74 73 20 | use sta|tements |
|00002820| 6c 69 6b 65 0d 0a 5c 62 | 65 67 69 6e 7b 76 65 72 |like..\b|egin{ver|
|00002830| 62 61 74 69 6d 7d 0d 0a | 20 20 20 20 20 20 20 20 |batim}..| |
|00002840| 20 20 20 20 20 20 20 20 | 4d 41 54 31 2e 4d 28 69 | |MAT1.M(i|
|00002850| 2c 6a 29 20 3d 20 4d 41 | 54 32 2e 6d 28 69 2c 6a |,j) = MA|T2.m(i,j|
|00002860| 29 3b 20 0d 0a 20 20 20 | 20 20 20 20 20 20 20 20 |); .. | |
|00002870| 20 20 20 20 20 4d 41 54 | 31 2e 4d 28 69 2c 6a 29 | MAT|1.M(i,j)|
|00002880| 20 3d 20 61 64 6f 75 62 | 6c 65 3b 0d 0a 20 20 20 | = adoub|le;.. |
|00002890| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 4d 61 74 | | Mat|
|000028a0| 70 6f 69 6e 74 65 72 31 | 2d 3e 4d 28 69 2c 6a 29 |pointer1|->M(i,j)|
|000028b0| 20 3d 20 4d 61 74 70 6f | 69 6e 74 65 72 32 2d 3e | = Matpo|inter2->|
|000028c0| 6d 28 69 2c 6a 29 3b 0d | 0a 20 20 20 20 20 20 20 |m(i,j);.|. |
|000028d0| 20 20 20 20 20 20 20 20 | 20 4d 61 74 70 6f 69 6e | | Matpoin|
|000028e0| 74 65 72 31 2d 3e 4d 28 | 69 2c 6a 29 20 3d 20 61 |ter1->M(|i,j) = a|
|000028f0| 6e 6f 74 68 65 72 5f 64 | 6f 75 62 6c 65 3b 0d 0a |nother_d|ouble;..|
|00002900| 5c 65 6e 64 7b 76 65 72 | 62 61 74 69 6d 7d 0d 0a |\end{ver|batim}..|
|00002910| 77 68 65 72 65 20 4d 41 | 54 31 20 61 6e 64 20 4d |where MA|T1 and M|
|00002920| 41 54 32 20 61 72 65 20 | 76 69 72 74 75 61 6c 20 |AT2 are |virtual |
|00002930| 6d 61 74 72 69 63 65 73 | 2c 20 61 6e 64 20 4d 61 |matrices|, and Ma|
|00002940| 74 70 6f 69 6e 74 65 72 | 73 0d 0a 61 72 65 20 70 |tpointer|s..are p|
|00002950| 6f 69 6e 74 65 72 73 20 | 74 6f 20 76 69 72 74 75 |ointers |to virtu|
|00002960| 61 6c 20 6d 61 74 72 69 | 63 65 73 2e 20 54 68 65 |al matri|ces. The|
|00002970| 20 62 61 73 69 63 20 69 | 64 65 61 20 61 74 20 77 | basic i|dea at w|
|00002980| 6f 72 6b 0d 0a 68 65 72 | 65 20 69 73 20 74 68 61 |ork..her|e is tha|
|00002990| 74 20 61 20 76 69 72 74 | 75 61 6c 20 6d 61 74 72 |t a virt|ual matr|
|000029a0| 69 78 20 69 73 20 64 65 | 72 69 76 65 64 20 66 72 |ix is de|rived fr|
|000029b0| 6f 6d 20 74 68 65 20 76 | 69 72 74 75 61 6c 0d 0a |om the v|irtual..|
|000029c0| 76 65 63 74 6f 72 2e 20 | 54 68 65 20 76 65 63 74 |vector. |The vect|
|000029d0| 6f 72 20 66 75 6e 63 74 | 69 6f 6e 73 20 61 72 65 |or funct|ions are|
|000029e0| 20 61 76 61 69 6c 61 62 | 6c 65 20 74 6f 20 74 68 | availab|le to th|
|000029f0| 65 20 6d 61 74 72 69 78 | 0d 0a 63 6c 61 73 73 2c |e matrix|..class,|
|00002a00| 20 61 6e 64 20 73 6f 20 | 61 73 73 69 67 6e 6d 65 | and so |assignme|
|00002a10| 6e 74 20 6f 66 20 6d 61 | 74 72 69 78 20 65 6c 65 |nt of ma|trix ele|
|00002a20| 6d 65 6e 74 73 20 77 6f | 72 6b 73 20 6a 75 73 74 |ments wo|rks just|
|00002a30| 20 61 73 0d 0a 69 6e 20 | 76 69 72 74 75 61 6c 20 | as..in |virtual |
|00002a40| 76 65 63 74 6f 72 73 2e | 20 54 68 65 20 6f 6e 6c |vectors.| The onl|
|00002a50| 79 20 64 69 66 66 65 72 | 65 6e 63 65 20 69 73 20 |y differ|ence is |
|00002a60| 74 68 61 74 20 74 68 65 | 20 69 6e 64 65 78 0d 0a |that the| index..|
|00002a70| 68 61 73 20 74 6f 20 62 | 65 20 63 61 6c 63 75 6c |has to b|e calcul|
|00002a80| 61 74 65 64 20 62 65 66 | 6f 72 65 20 74 68 65 20 |ated bef|ore the |
|00002a90| 76 65 63 74 6f 72 20 66 | 75 6e 63 74 69 6f 6e 73 |vector f|unctions|
|00002aa0| 20 63 61 6e 20 62 65 0d | 0a 63 61 6c 6c 65 64 2e | can be.|.called.|
|00002ab0| 20 54 68 65 20 63 6f 64 | 65 20 66 6f 72 20 61 73 | The cod|e for as|
|00002ac0| 73 69 67 6e 69 6e 67 20 | 61 6e 20 65 6c 65 6d 65 |signing |an eleme|
|00002ad0| 6e 74 20 69 73 0d 0a 5c | 62 65 67 69 6e 7b 76 65 |nt is..\|begin{ve|
|00002ae0| 72 62 61 74 69 6d 7d 0d | 0a 20 20 20 64 6f 75 62 |rbatim}.|. doub|
|00002af0| 6c 65 20 6f 70 65 72 61 | 74 6f 72 20 3d 20 28 20 |le opera|tor = ( |
|00002b00| 64 6f 75 62 6c 65 20 64 | 20 29 7b 20 20 20 20 20 |double d| ){ |
|00002b10| 2f 2f 20 77 72 69 74 65 | 20 69 6e 20 61 20 76 61 |// write| in a va|
|00002b20| 6c 75 65 0d 0a 20 20 20 | 20 20 76 64 6f 75 62 3a |lue.. | vdoub:|
|00002b30| 3a 6f 70 65 72 61 74 6f | 72 5b 5d 28 63 75 72 76 |:operato|r[](curv|
|00002b40| 65 63 69 6e 64 29 20 3d | 20 64 3b 0d 0a 20 20 20 |ecind) =| d;.. |
|00002b50| 20 20 72 65 74 75 72 6e | 20 64 3b 0d 0a 20 20 20 | return| d;.. |
|00002b60| 7d 0d 0a 5c 65 6e 64 7b | 76 65 72 62 61 74 69 6d |}..\end{|verbatim|
|00002b70| 7d 0d 0a 54 68 65 20 73 | 63 6f 70 65 20 72 65 73 |}..The s|cope res|
|00002b80| 6f 6c 75 74 69 6f 6e 20 | 6f 70 65 72 61 74 6f 72 |olution |operator|
|00002b90| 20 69 73 20 72 65 71 75 | 69 72 65 64 20 74 6f 20 | is requ|ired to |
|00002ba0| 74 65 6c 6c 20 74 68 65 | 0d 0a 63 6f 6d 70 69 6c |tell the|..compil|
|00002bb0| 65 72 20 74 6f 20 75 73 | 65 20 74 68 65 20 65 71 |er to us|e the eq|
|00002bc0| 75 61 6c 73 20 6f 70 65 | 72 61 74 6f 72 20 66 72 |uals ope|rator fr|
|00002bd0| 6f 6d 20 74 68 65 20 70 | 61 72 65 6e 74 20 63 6c |om the p|arent cl|
|00002be0| 61 73 73 0d 0a 72 61 74 | 68 65 72 20 74 68 61 6e |ass..rat|her than|
|00002bf0| 20 74 68 65 20 56 4d 61 | 74 72 69 78 20 63 6c 61 | the VMa|trix cla|
|00002c00| 73 73 2e 20 0d 0a 0d 0a | 5c 73 75 62 73 65 63 74 |ss. ....|\subsect|
|00002c10| 69 6f 6e 7b 41 73 73 69 | 67 6e 6d 65 6e 74 20 6f |ion{Assi|gnment o|
|00002c20| 66 20 4d 61 74 72 69 63 | 65 73 7d 0d 0a 0d 0a 4d |f Matric|es}....M|
|00002c30| 61 74 72 69 78 20 61 73 | 73 69 67 6e 6d 65 6e 74 |atrix as|signment|
|00002c40| 20 75 73 65 73 20 73 74 | 61 74 65 6d 65 6e 74 73 | uses st|atements|
|00002c50| 20 6c 69 6b 65 20 22 41 | 3d 42 3b 22 20 77 68 65 | like "A|=B;" whe|
|00002c60| 72 65 20 41 20 61 6e 64 | 20 42 0d 0a 61 72 65 20 |re A and| B..are |
|00002c70| 6d 61 74 72 69 63 65 73 | 2e 20 54 68 65 20 6f 70 |matrices|. The op|
|00002c80| 65 72 61 74 6f 72 20 69 | 73 20 74 68 65 20 66 75 |erator i|s the fu|
|00002c90| 6e 63 74 69 6f 6e 20 67 | 69 76 65 6e 20 62 79 20 |nction g|iven by |
|00002ca0| 74 68 65 20 63 6f 64 65 | 0d 0a 5c 62 65 67 69 6e |the code|..\begin|
|00002cb0| 7b 76 65 72 62 61 74 69 | 6d 7d 0d 0a 76 6f 69 64 |{verbati|m}..void|
|00002cc0| 20 56 4d 61 74 72 69 78 | 3a 3a 6f 70 65 72 61 74 | VMatrix|::operat|
|00002cd0| 6f 72 3d 20 28 56 4d 61 | 74 72 69 78 20 26 52 4f |or= (VMa|trix &RO|
|00002ce0| 70 29 0d 0a 7b 0d 0a 20 | 20 20 20 47 61 72 62 61 |p)..{.. | Garba|
|00002cf0| 67 65 28 22 6f 70 65 72 | 61 74 6f 72 20 3d 22 29 |ge("oper|ator =")|
|00002d00| 3b 0d 0a 20 20 20 20 52 | 4f 70 2e 47 61 72 62 61 |;.. R|Op.Garba|
|00002d10| 67 65 28 22 6f 70 65 72 | 61 74 6f 72 20 3d 22 29 |ge("oper|ator =")|
|00002d20| 3b 0d 0a 20 20 20 20 52 | 65 70 6c 61 63 65 28 20 |;.. R|eplace( |
|00002d30| 52 4f 70 20 29 3b 0d 0a | 20 20 20 20 44 69 73 70 |ROp );..| Disp|
|00002d40| 61 74 63 68 2d 3e 43 6c | 65 61 6e 73 74 61 63 6b |atch->Cl|eanstack|
|00002d50| 28 29 3b 0d 0a 7d 0d 0a | 5c 65 6e 64 7b 76 65 72 |();..}..|\end{ver|
|00002d60| 62 61 74 69 6d 7d 0d 0a | 54 68 65 20 6f 70 65 72 |batim}..|The oper|
|00002d70| 61 6e 64 73 20 61 72 65 | 20 63 68 65 63 6b 65 64 |ands are| checked|
|00002d80| 20 66 6f 72 20 76 61 6c | 69 64 69 74 79 2e 20 54 | for val|idity. T|
|00002d90| 68 65 20 6c 65 66 74 20 | 6f 70 65 72 61 6e 64 20 |he left |operand |
|00002da0| 68 61 73 0d 0a 69 74 73 | 20 68 65 61 64 65 72 20 |has..its| header |
|00002db0| 72 65 70 6c 61 63 65 64 | 2e 20 54 68 65 6e 2c 20 |replaced|. Then, |
|00002dc0| 61 6e 79 20 69 6e 74 65 | 72 6d 65 64 69 61 74 65 |any inte|rmediate|
|00002dd0| 20 73 74 61 63 6b 20 6d | 61 74 72 69 63 65 73 0d | stack m|atrices.|
|00002de0| 0a 61 72 65 20 72 65 6d | 6f 76 65 64 20 66 72 6f |.are rem|oved fro|
|00002df0| 6d 20 74 68 65 20 73 74 | 61 63 6b 2e 0d 0a 0d 0a |m the st|ack.....|
|00002e00| 43 6c 65 61 6e 73 74 61 | 63 6b 28 29 20 77 69 6c |Cleansta|ck() wil|
|00002e10| 6c 20 62 65 20 64 69 73 | 63 75 73 73 65 64 20 69 |l be dis|cussed i|
|00002e20| 6e 20 74 68 65 20 63 68 | 61 70 74 65 72 20 6f 6e |n the ch|apter on|
|00002e30| 20 74 68 65 20 6d 61 74 | 72 69 78 0d 0a 73 74 61 | the mat|rix..sta|
|00002e40| 63 6b 2e 20 42 61 73 69 | 63 61 6c 6c 79 20 69 74 |ck. Basi|cally it|
|00002e50| 20 73 65 72 76 65 73 20 | 74 6f 20 64 69 73 70 6f | serves |to dispo|
|00002e60| 73 65 20 6f 66 20 74 68 | 65 20 69 6e 74 65 72 6d |se of th|e interm|
|00002e70| 65 64 69 61 74 65 0d 0a | 72 65 73 75 6c 74 73 20 |ediate..|results |
|00002e80| 6f 66 20 61 20 72 65 70 | 65 61 74 65 64 20 63 61 |of a rep|eated ca|
|00002e90| 6c 63 75 6c 61 74 69 6f | 6e 2e 20 53 75 70 70 6f |lculatio|n. Suppo|
|00002ea0| 73 65 20 79 6f 75 20 75 | 73 65 20 74 68 65 0d 0a |se you u|se the..|
|00002eb0| 73 74 61 74 65 6d 65 6e | 74 20 5c 76 65 72 62 23 |statemen|t \verb#|
|00002ec0| 20 63 3d 61 2b 62 2b 64 | 20 23 2e 20 54 68 65 20 | c=a+b+d| #. The |
|00002ed0| 73 75 6d 20 62 2b 64 20 | 69 73 20 63 61 6c 63 75 |sum b+d |is calcu|
|00002ee0| 6c 61 74 65 64 2c 20 74 | 68 65 6e 0d 0a 61 64 64 |lated, t|hen..add|
|00002ef0| 65 64 20 74 6f 20 61 2c | 20 61 6e 64 20 74 68 65 |ed to a,| and the|
|00002f00| 20 72 65 73 75 6c 74 20 | 69 73 20 61 73 73 69 67 | result |is assig|
|00002f10| 6e 65 64 20 74 6f 20 63 | 2e 20 54 68 65 0d 0a 69 |ned to c|. The..i|
|00002f20| 6e 74 65 72 6d 65 64 69 | 61 74 65 20 63 61 6c 63 |ntermedi|ate calc|
|00002f30| 75 6c 61 74 69 6f 6e 20 | 6f 66 20 62 2b 64 20 69 |ulation |of b+d i|
|00002f40| 73 20 73 74 69 6c 6c 20 | 6f 6e 20 74 68 65 20 68 |s still |on the h|
|00002f50| 65 61 70 20 69 6e 20 74 | 68 65 0d 0a 73 74 61 63 |eap in t|he..stac|
|00002f60| 6b 2e 20 20 43 6c 65 61 | 6e 73 74 61 63 6b 28 29 |k. Clea|nstack()|
|00002f70| 5c 69 6e 64 65 78 7b 4d | 53 74 61 63 6b 21 43 6c |\index{M|Stack!Cl|
|00002f80| 65 61 6e 73 74 61 63 6b | 28 29 7d 20 72 65 6d 6f |eanstack|()} remo|
|00002f90| 76 65 73 20 62 2b 64 20 | 61 6e 64 0d 0a 61 2b 28 |ves b+d |and..a+(|
|00002fa0| 62 2b 64 29 20 66 72 6f | 6d 20 74 68 65 20 73 74 |b+d) fro|m the st|
|00002fb0| 61 63 6b 2e 20 0d 0a 0d | 0a 0d 0a 5c 73 75 62 73 |ack. ...|...\subs|
|00002fc0| 65 63 74 69 6f 6e 7b 43 | 6f 6e 73 74 72 75 63 74 |ection{C|onstruct|
|00002fd0| 6f 72 73 20 61 6e 64 20 | 44 65 73 74 72 75 63 74 |ors and |Destruct|
|00002fe0| 6f 72 73 7d 0d 0a 0d 0a | 54 68 65 72 65 20 61 72 |ors}....|There ar|
|00002ff0| 65 20 74 68 72 65 65 20 | 63 6f 6e 73 74 72 75 63 |e three |construc|
|00003000| 74 6f 72 73 20 66 6f 72 | 20 56 4d 61 74 72 69 63 |tors for| VMatric|
|00003010| 65 73 2e 20 54 68 65 20 | 64 65 66 61 75 6c 74 0d |es. The |default.|
|00003020| 0a 63 6f 6e 73 74 72 75 | 63 74 6f 72 20 74 61 6b |.constru|ctor tak|
|00003030| 65 73 20 61 20 76 6f 69 | 64 20 61 72 67 75 6d 65 |es a voi|d argume|
|00003040| 6e 74 2e 20 4e 6f 74 65 | 20 74 68 61 74 20 73 69 |nt. Note| that si|
|00003050| 6e 63 65 20 61 0d 0a 56 | 4d 61 74 72 69 78 20 69 |nce a..V|Matrix i|
|00003060| 73 20 61 20 73 75 62 2d | 63 6c 61 73 73 20 6f 66 |s a sub-|class of|
|00003070| 20 61 20 76 64 6f 75 62 | 2c 20 74 68 65 20 76 64 | a vdoub|, the vd|
|00003080| 6f 75 62 20 63 6f 6e 73 | 74 72 75 63 74 6f 72 20 |oub cons|tructor |
|00003090| 69 73 0d 0a 63 61 6c 6c | 65 64 20 66 69 72 73 74 |is..call|ed first|
|000030a0| 2e 20 54 68 65 20 65 78 | 74 72 61 20 56 4d 61 74 |. The ex|tra VMat|
|000030b0| 72 69 78 20 65 6c 65 6d | 65 6e 74 73 20 61 72 65 |rix elem|ents are|
|000030c0| 20 73 75 70 70 6c 69 65 | 64 20 6e 65 78 74 2e 0d | supplie|d next..|
|000030d0| 0a 54 68 65 20 64 65 66 | 61 75 6c 74 20 63 6f 6e |.The def|ault con|
|000030e0| 73 74 72 75 63 74 6f 72 | 5c 69 6e 64 65 78 7b 56 |structor|\index{V|
|000030f0| 4d 61 74 72 69 78 21 63 | 6f 6e 73 74 72 75 63 74 |Matrix!c|onstruct|
|00003100| 6f 72 7d 20 73 65 74 73 | 20 74 68 65 0d 0a 6e 61 |or} sets| the..na|
|00003110| 6d 65 20 74 6f 20 27 74 | 27 2c 20 61 6e 64 20 61 |me to 't|', and a|
|00003120| 6c 6c 6f 63 61 74 65 73 | 20 61 20 31 78 31 20 6d |llocates| a 1x1 m|
|00003130| 61 74 72 69 78 2e 0d 0a | 0d 0a 54 68 65 20 73 65 |atrix...|..The se|
|00003140| 63 6f 6e 64 20 66 6f 72 | 6d 20 6f 66 20 74 68 65 |cond for|m of the|
|00003150| 20 63 6f 6e 73 74 72 75 | 63 74 6f 72 20 69 73 20 | constru|ctor is |
|00003160| 67 69 76 65 6e 20 69 6e | 20 74 68 65 20 63 6f 64 |given in| the cod|
|00003170| 65 20 62 65 6c 6f 77 3a | 0d 0a 5c 62 65 67 69 6e |e below:|..\begin|
|00003180| 7b 76 65 72 62 61 74 69 | 6d 7d 0d 0a 56 4d 61 74 |{verbati|m}..VMat|
|00003190| 72 69 78 3a 3a 56 4d 61 | 74 72 69 78 28 20 63 6f |rix::VMa|trix( co|
|000031a0| 6e 73 74 20 63 68 61 72 | 20 2a 73 74 72 2c 20 69 |nst char| *str, i|
|000031b0| 6e 74 20 72 72 2c 20 69 | 6e 74 20 63 63 29 3a 0d |nt rr, i|nt cc):.|
|000031c0| 0a 20 20 20 20 76 64 6f | 75 62 28 20 28 28 6c 6f |. vdo|ub( ((lo|
|000031d0| 6e 67 20 29 28 28 6c 6f | 6e 67 29 20 72 72 29 2a |ng )((lo|ng) rr)*|
|000031e0| 28 28 6c 6f 6e 67 29 20 | 63 63 29 29 20 29 0d 0a |((long) |cc)) )..|
|000031f0| 20 20 7b 0d 0a 20 20 20 | 20 72 3d 72 72 3b 0d 0a | {.. | r=rr;..|
|00003200| 20 20 20 20 63 3d 63 63 | 3b 0d 0a 20 20 20 20 63 | c=cc|;.. c|
|00003210| 75 72 76 65 63 69 6e 64 | 20 3d 20 30 3b 0d 0a 20 |urvecind| = 0;.. |
|00003220| 20 20 20 4e 61 6d 65 69 | 74 28 20 73 74 72 20 29 | Namei|t( str )|
|00003230| 3b 0d 0a 20 20 20 20 73 | 69 67 6e 61 74 75 72 65 |;.. s|ignature|
|00003240| 20 3d 20 53 49 47 4e 41 | 54 55 52 45 3b 0d 0a 20 | = SIGNA|TURE;.. |
|00003250| 20 7d 0d 0a 5c 65 6e 64 | 7b 76 65 72 62 61 74 69 | }..\end|{verbati|
|00003260| 6d 7d 0d 0a 54 68 65 20 | 73 65 63 6f 6e 64 20 6c |m}..The |second l|
|00003270| 69 6e 65 20 6f 66 20 74 | 68 69 73 20 63 6f 6e 73 |ine of t|his cons|
|00003280| 74 72 75 63 74 6f 72 20 | 63 61 6c 6c 73 20 74 68 |tructor |calls th|
|00003290| 65 20 76 64 6f 75 62 0d | 0a 63 6f 6e 73 74 72 75 |e vdoub.|.constru|
|000032a0| 63 74 6f 72 20 77 69 74 | 68 20 61 20 64 65 66 61 |ctor wit|h a defa|
|000032b0| 75 6c 74 20 76 65 63 74 | 6f 72 20 6c 65 6e 67 74 |ult vect|or lengt|
|000032c0| 68 20 6f 66 20 72 72 2a | 63 63 2e 20 54 68 65 0d |h of rr*|cc. The.|
|000032d0| 0a 63 61 73 74 73 20 61 | 76 6f 69 64 20 74 79 70 |.casts a|void typ|
|000032e0| 65 20 70 72 6f 6d 6f 74 | 69 6f 6e 20 70 72 6f 62 |e promot|ion prob|
|000032f0| 6c 65 6d 73 2e 20 54 68 | 65 20 63 6f 6e 73 74 72 |lems. Th|e constr|
|00003300| 75 63 74 6f 72 20 73 65 | 74 73 0d 0a 74 68 65 20 |uctor se|ts..the |
|00003310| 6e 61 6d 65 20 74 6f 20 | 74 68 65 20 73 75 70 70 |name to |the supp|
|00003320| 6c 69 65 64 20 73 74 72 | 69 6e 67 2e 20 0d 0a 0d |lied str|ing. ...|
|00003330| 0a 54 68 65 20 74 68 69 | 72 64 20 63 6f 6e 73 74 |.The thi|rd const|
|00003340| 72 75 63 74 6f 72 20 69 | 73 20 61 20 63 6f 70 79 |ructor i|s a copy|
|00003350| 20 63 6f 6e 73 74 72 75 | 63 74 6f 72 2e 20 54 68 | constru|ctor. Th|
|00003360| 69 73 20 61 6c 6c 6f 77 | 73 20 0d 0a 73 74 61 74 |is allow|s ..stat|
|00003370| 65 6d 65 6e 74 73 20 6c | 69 6b 65 20 5c 76 65 72 |ements l|ike \ver|
|00003380| 62 23 56 4d 61 74 72 69 | 78 20 63 20 3d 20 62 3b |b#VMatri|x c = b;|
|00003390| 23 20 74 6f 20 62 65 20 | 75 73 65 64 2e 0d 0a 54 |# to be |used...T|
|000033a0| 68 69 73 20 63 72 65 61 | 74 65 73 20 74 68 65 20 |his crea|tes the |
|000033b0| 6e 65 77 20 6d 61 74 72 | 69 78 20 63 2c 20 61 6e |new matr|ix c, an|
|000033c0| 64 20 74 68 65 6e 20 63 | 6f 70 69 65 73 20 62 20 |d then c|opies b |
|000033d0| 69 6e 74 6f 20 69 74 2e | 0d 0a 54 68 65 20 61 73 |into it.|..The as|
|000033e0| 73 69 67 6e 6d 65 6e 74 | 20 6d 61 79 20 61 6c 73 |signment| may als|
|000033f0| 6f 20 62 65 20 61 20 66 | 75 6e 63 74 69 6f 6e 20 |o be a f|unction |
|00003400| 63 61 6c 6c 2c 20 6f 72 | 20 72 65 70 65 61 74 65 |call, or| repeate|
|00003410| 64 0d 0a 6f 70 65 72 61 | 74 69 6f 6e 73 2e 20 4d |d..opera|tions. M|
|00003420| 61 74 72 69 78 20 70 6f | 69 6e 74 65 72 73 20 63 |atrix po|inters c|
|00003430| 61 6e 20 61 6c 73 6f 20 | 62 65 20 63 72 65 61 74 |an also |be creat|
|00003440| 65 64 20 62 79 0d 0a 66 | 75 6e 63 74 69 6f 6e 73 |ed by..f|unctions|
|00003450| 20 73 75 63 68 20 61 73 | 20 5c 76 65 72 62 23 20 | such as| \verb# |
|00003460| 56 4d 61 74 72 69 78 20 | 2a 4d 61 74 20 3d 20 6e |VMatrix |*Mat = n|
|00003470| 65 77 20 56 4d 61 74 72 | 69 78 3b 23 2e 0d 0a 4e |ew VMatr|ix;#...N|
|00003480| 6f 74 65 20 74 68 61 74 | 20 74 68 65 20 63 6f 70 |ote that| the cop|
|00003490| 79 20 63 6f 6e 73 74 72 | 75 63 74 6f 72 20 64 6f |y constr|uctor do|
|000034a0| 65 73 20 6e 6f 74 20 63 | 61 6c 6c 20 63 6c 65 61 |es not c|all clea|
|000034b0| 6e 73 74 61 63 6b 28 29 | 2c 20 73 6f 0d 0a 74 68 |nstack()|, so..th|
|000034c0| 65 20 73 74 61 63 6b 20 | 63 61 6e 20 67 72 6f 77 |e stack |can grow|
|000034d0| 20 71 75 69 74 65 20 6c | 61 72 67 65 20 69 66 20 | quite l|arge if |
|000034e0| 69 74 20 69 73 20 6e 6f | 74 20 63 6c 65 61 72 65 |it is no|t cleare|
|000034f0| 64 20 62 79 20 6d 61 74 | 72 69 78 0d 0a 61 73 73 |d by mat|rix..ass|
|00003500| 69 67 6e 6d 65 6e 74 2e | 20 0d 0a 0d 0a 54 68 65 |ignment.| ....The|
|00003510| 20 64 65 73 74 72 75 63 | 74 6f 72 5c 69 6e 64 65 | destruc|tor\inde|
|00003520| 78 7b 56 4d 61 74 72 69 | 78 21 64 65 73 74 72 75 |x{VMatri|x!destru|
|00003530| 63 74 6f 72 7d 20 66 69 | 72 73 74 20 63 61 6c 6c |ctor} fi|rst call|
|00003540| 73 20 74 68 65 0d 0a 64 | 65 73 74 72 75 63 74 6f |s the..d|estructo|
|00003550| 72 20 66 6f 72 20 74 68 | 65 20 76 64 6f 75 62 2c |r for th|e vdoub,|
|00003560| 20 72 65 74 75 72 6e 73 | 2c 20 61 6e 64 20 73 65 | returns|, and se|
|00003570| 74 73 20 74 68 65 20 73 | 69 67 6e 61 74 75 72 65 |ts the s|ignature|
|00003580| 0d 0a 74 6f 20 7a 65 72 | 6f 2e 0d 0a 0d 0a 5c 73 |..to zer|o.....\s|
|00003590| 75 62 73 65 63 74 69 6f | 6e 7b 54 68 65 20 4e 61 |ubsectio|n{The Na|
|000035a0| 6d 69 6e 67 20 46 75 6e | 63 74 69 6f 6e 73 7d 0d |ming Fun|ctions}.|
|000035b0| 0a 0d 0a 54 68 65 20 6e | 61 6d 69 6e 67 20 66 75 |...The n|aming fu|
|000035c0| 6e 63 74 69 6f 6e 73 20 | 73 74 6f 72 65 20 74 68 |nctions |store th|
|000035d0| 65 20 6e 61 6d 65 2c 20 | 72 65 74 72 69 65 76 65 |e name, |retrieve|
|000035e0| 20 74 68 65 20 6e 61 6d | 65 2c 0d 0a 64 69 73 70 | the nam|e,..disp|
|000035f0| 6c 61 79 20 74 68 65 20 | 6e 61 6d 65 2c 20 6f 72 |lay the |name, or|
|00003600| 20 72 65 74 75 72 6e 20 | 74 68 65 20 61 64 64 72 | return |the addr|
|00003610| 65 73 73 20 6f 66 20 74 | 68 65 20 6e 61 6d 65 2e |ess of t|he name.|
|00003620| 20 54 68 65 0d 0a 66 75 | 6e 63 74 69 6f 6e 20 4e | The..fu|nction N|
|00003630| 61 6d 65 69 74 28 29 5c | 69 6e 64 65 78 7b 56 4d |ameit()\|index{VM|
|00003640| 61 74 72 69 78 21 4e 61 | 6d 65 69 74 28 29 7d 20 |atrix!Na|meit()} |
|00003650| 61 63 63 65 70 74 73 20 | 73 74 72 69 6e 67 0d 0a |accepts |string..|
|00003660| 63 6f 6e 73 74 61 6e 74 | 73 2c 20 56 4d 61 74 72 |constant|s, VMatr|
|00003670| 69 78 20 72 65 66 65 72 | 65 6e 63 65 73 2c 20 6f |ix refer|ences, o|
|00003680| 72 20 73 74 72 69 6e 67 | 20 6f 62 6a 65 63 74 73 |r string| objects|
|00003690| 2e 20 54 68 65 0d 0a 70 | 72 6f 70 65 72 20 66 75 |. The..p|roper fu|
|000036a0| 6e 63 74 69 6f 6e 73 20 | 61 72 65 20 63 61 6c 6c |nctions |are call|
|000036b0| 65 64 20 74 6f 20 61 73 | 73 69 67 6e 20 74 68 65 |ed to as|sign the|
|000036c0| 20 6e 61 6d 65 20 74 6f | 20 74 68 65 0d 0a 6d 61 | name to| the..ma|
|000036d0| 74 72 69 78 2e 20 0d 0a | 0d 0a 54 68 65 20 66 75 |trix. ..|..The fu|
|000036e0| 6e 63 74 69 6f 6e 20 47 | 65 74 6e 61 6d 65 28 29 |nction G|etname()|
|000036f0| 5c 69 6e 64 65 78 7b 56 | 4d 61 74 72 69 78 21 67 |\index{V|Matrix!g|
|00003700| 65 74 6e 61 6d 65 28 29 | 7d 20 72 65 74 75 72 6e |etname()|} return|
|00003710| 73 20 61 0d 0a 73 74 72 | 69 6e 67 20 74 79 70 65 |s a..str|ing type|
|00003720| 20 6f 62 6a 65 63 74 20 | 63 6f 6e 74 61 69 6e 69 | object |containi|
|00003730| 6e 67 20 74 68 65 20 6e | 61 6d 65 20 6f 66 20 74 |ng the n|ame of t|
|00003740| 68 65 20 6d 61 74 72 69 | 78 2e 20 54 68 69 73 0d |he matri|x. This.|
|00003750| 0a 63 61 6e 20 62 65 20 | 75 73 65 64 20 69 6e 20 |.can be |used in |
|00003760| 63 6f 6e 63 61 74 65 6e | 61 74 69 6f 6e 20 61 6e |concaten|ation an|
|00003770| 64 20 61 73 73 69 67 6e | 6d 65 6e 74 20 77 69 74 |d assign|ment wit|
|00003780| 68 20 6f 74 68 65 72 0d | 0a 73 74 72 69 6e 67 73 |h other.|.strings|
|00003790| 2e 20 0d 0a 0d 0a 54 68 | 65 20 66 75 6e 63 74 69 |. ....Th|e functi|
|000037a0| 6f 6e 20 53 74 72 69 6e | 67 41 64 64 72 65 73 73 |on Strin|gAddress|
|000037b0| 28 29 20 72 65 74 75 72 | 6e 73 20 74 68 65 20 61 |() retur|ns the a|
|000037c0| 64 64 72 65 73 73 20 6f | 66 20 74 68 65 0d 0a 6d |ddress o|f the..m|
|000037d0| 61 74 72 69 78 20 6e 61 | 6d 65 2e 20 54 68 69 73 |atrix na|me. This|
|000037e0| 20 66 75 6e 63 74 69 6f | 6e 20 69 73 20 75 73 65 | functio|n is use|
|000037f0| 64 20 69 6e 20 74 68 65 | 20 57 72 69 74 65 62 20 |d in the| Writeb |
|00003800| 61 6e 64 20 57 72 69 74 | 65 61 0d 0a 66 75 6e 63 |and Writ|ea..func|
|00003810| 74 69 6f 6e 73 20 77 68 | 65 72 65 20 61 6e 20 61 |tions wh|ere an a|
|00003820| 64 64 72 65 73 73 20 69 | 73 20 75 73 65 64 2e 20 |ddress i|s used. |
|00003830| 54 68 69 73 20 66 75 6e | 63 74 69 6f 6e 20 6d 61 |This fun|ction ma|
|00003840| 79 20 6e 6f 74 0d 0a 62 | 65 20 6f 66 20 6d 75 63 |y not..b|e of muc|
|00003850| 68 20 75 73 65 20 6f 74 | 68 65 72 77 69 73 65 2e |h use ot|herwise.|
|00003860| 20 59 6f 75 20 73 68 6f | 75 6c 64 20 6e 6f 74 20 | You sho|uld not |
|00003870| 6d 61 6e 69 70 75 6c 61 | 74 65 20 74 68 65 0d 0a |manipula|te the..|
|00003880| 6e 61 6d 65 20 64 69 72 | 65 63 74 6c 79 2c 20 65 |name dir|ectly, e|
|00003890| 76 65 6e 20 74 68 6f 75 | 67 68 20 79 6f 75 20 6b |ven thou|gh you k|
|000038a0| 6e 6f 77 20 69 74 73 20 | 62 61 73 65 20 61 64 64 |now its |base add|
|000038b0| 72 65 73 73 2e 20 4c 65 | 74 0d 0a 74 68 65 20 73 |ress. Le|t..the s|
|000038c0| 74 72 69 6e 67 20 63 6c | 61 73 73 20 6d 65 6d 62 |tring cl|ass memb|
|000038d0| 65 72 20 66 75 6e 63 74 | 69 6f 6e 73 20 64 6f 20 |er funct|ions do |
|000038e0| 69 74 20 66 6f 72 20 79 | 6f 75 2e 0d 0a 0d 0a 5c |it for y|ou.....\|
|000038f0| 73 75 62 73 65 63 74 69 | 6f 6e 7b 4f 74 68 65 72 |subsecti|on{Other|
|00003900| 20 53 65 72 76 69 63 65 | 20 46 75 6e 63 74 69 6f | Service| Functio|
|00003910| 6e 73 7d 0d 0a 0d 0a 53 | 6f 6d 65 20 6f 74 68 65 |ns}....S|ome othe|
|00003920| 72 20 73 65 72 76 69 63 | 65 20 66 75 6e 63 74 69 |r servic|e functi|
|00003930| 6f 6e 73 20 61 72 65 20 | 61 76 61 69 6c 61 62 6c |ons are |availabl|
|00003940| 65 2e 20 54 68 65 20 66 | 69 72 73 74 20 69 73 0d |e. The f|irst is.|
|00003950| 0a 4c 6f 61 64 6d 61 74 | 28 29 5c 69 6e 64 65 78 |.Loadmat|()\index|
|00003960| 7b 56 4d 61 74 72 69 78 | 21 4c 6f 61 64 6d 61 74 |{VMatrix|!Loadmat|
|00003970| 28 29 7d 20 77 68 69 63 | 68 20 61 6c 6c 6f 77 73 |()} whic|h allows|
|00003980| 20 74 68 65 20 75 73 65 | 72 20 74 6f 0d 0a 65 6e | the use|r to..en|
|00003990| 74 65 72 20 61 20 6d 61 | 74 72 69 78 20 69 6e 74 |ter a ma|trix int|
|000039a0| 65 72 61 63 74 69 76 65 | 6c 79 2e 20 54 6f 20 75 |eractive|ly. To u|
|000039b0| 73 65 20 74 68 69 73 20 | 66 75 6e 63 74 69 6f 6e |se this |function|
|000039c0| 20 74 6f 20 65 6e 74 65 | 72 0d 0a 74 68 65 20 65 | to ente|r..the e|
|000039d0| 6c 65 6d 65 6e 74 73 20 | 6f 66 20 61 20 6d 61 74 |lements |of a mat|
|000039e0| 72 69 78 2c 20 75 73 65 | 20 63 6f 64 65 20 73 75 |rix, use| code su|
|000039f0| 63 68 20 61 73 20 5c 76 | 65 72 62 23 0d 0a 41 2e |ch as \v|erb#..A.|
|00003a00| 4c 6f 61 64 6d 61 74 28 | 29 23 20 6f 72 20 5c 76 |Loadmat(|)# or \v|
|00003a10| 65 72 62 23 20 41 2d 3e | 4c 6f 61 64 6d 61 74 28 |erb# A->|Loadmat(|
|00003a20| 29 23 2e 20 54 68 65 20 | 70 72 6f 67 72 61 6d 20 |)#. The |program |
|00003a30| 77 69 6c 6c 20 73 74 6f | 70 0d 0a 61 6e 64 20 6c |will sto|p..and l|
|00003a40| 65 74 20 79 6f 75 20 65 | 6e 74 65 72 20 74 68 65 |et you e|nter the|
|00003a50| 20 6d 61 74 72 69 78 20 | 65 6c 65 6d 65 6e 74 73 | matrix |elements|
|00003a60| 20 61 74 20 74 68 65 20 | 74 65 72 6d 69 6e 61 6c | at the |terminal|
|00003a70| 2e 20 0d 0a 0d 0a 44 69 | 73 70 6c 61 79 4d 61 74 |. ....Di|splayMat|
|00003a80| 28 29 5c 69 6e 64 65 78 | 7b 56 4d 61 74 72 69 78 |()\index|{VMatrix|
|00003a90| 21 44 69 73 70 6c 61 79 | 4d 61 74 28 29 7d 20 61 |!Display|Mat()} a|
|00003aa0| 6e 64 0d 0a 49 6e 66 6f | 4d 61 74 28 29 5c 69 6e |nd..Info|Mat()\in|
|00003ab0| 64 65 78 7b 56 4d 61 74 | 72 69 78 21 49 6e 66 6f |dex{VMat|rix!Info|
|00003ac0| 6d 61 74 28 29 7d 20 64 | 69 73 70 6c 61 79 20 74 |mat()} d|isplay t|
|00003ad0| 68 65 20 6d 61 74 72 69 | 78 20 61 6e 64 0d 0a 74 |he matri|x and..t|
|00003ae0| 68 65 20 64 69 6d 65 6e | 73 69 6f 6e 73 20 6f 66 |he dimen|sions of|
|00003af0| 20 74 68 65 20 61 63 74 | 69 76 65 20 6d 61 74 72 | the act|ive matr|
|00003b00| 69 63 65 73 2e 20 59 6f | 75 20 63 61 6e 20 61 64 |ices. Yo|u can ad|
|00003b10| 64 20 6d 6f 72 65 0d 0a | 63 68 65 63 6b 73 20 61 |d more..|checks a|
|00003b20| 73 20 79 6f 75 20 77 61 | 6e 74 2e 20 55 73 65 20 |s you wa|nt. Use |
|00003b30| 74 68 65 20 66 75 6e 63 | 74 69 6f 6e 73 0d 0a 53 |the func|tions..S|
|00003b40| 65 74 77 69 64 28 29 5c | 69 6e 64 65 78 7b 66 75 |etwid()\|index{fu|
|00003b50| 6e 63 74 69 6f 6e 73 21 | 53 65 74 77 69 64 28 29 |nctions!|Setwid()|
|00003b60| 7d 20 61 6e 64 20 53 65 | 74 64 65 63 28 29 5c 69 |} and Se|tdec()\i|
|00003b70| 6e 64 65 78 7b 66 75 6e | 63 74 69 6f 6e 73 21 53 |ndex{fun|ctions!S|
|00003b80| 65 74 64 65 63 28 29 7d | 20 74 6f 0d 0a 63 6f 6e |etdec()}| to..con|
|00003b90| 74 72 6f 6c 20 74 68 65 | 20 64 69 73 70 6c 61 79 |trol the| display|
|00003ba0| 65 64 20 77 69 64 74 68 | 20 6f 66 20 74 68 65 20 |ed width| of the |
|00003bb0| 6e 75 6d 62 65 72 73 20 | 61 6e 64 20 74 68 65 20 |numbers |and the |
|00003bc0| 6e 75 6d 62 65 72 0d 0a | 6f 66 20 64 65 63 69 6d |number..|of decim|
|00003bd0| 61 6c 73 2e 0d 0a 0d 0a | 57 72 69 74 65 62 28 63 |als.....|Writeb(c|
|00003be0| 68 61 72 20 2a 66 69 64 | 2c 20 56 4d 61 74 72 69 |har *fid|, VMatri|
|00003bf0| 78 20 5c 26 6d 61 74 29 | 5c 69 6e 64 65 78 7b 66 |x \&mat)|\index{f|
|00003c00| 75 6e 63 74 69 6f 6e 73 | 21 57 72 69 74 65 62 28 |unctions|!Writeb(|
|00003c10| 29 7d 20 64 6f 65 73 6e | 27 74 0d 0a 72 65 61 6c |)} doesn|'t..real|
|00003c20| 6c 79 20 62 65 6c 6f 6e | 67 20 61 73 20 6d 65 6d |ly belon|g as mem|
|00003c30| 62 65 72 20 66 75 6e 63 | 74 69 6f 6e 2c 20 62 75 |ber func|tion, bu|
|00003c40| 74 20 6e 65 65 64 73 20 | 61 63 63 65 73 73 20 74 |t needs |access t|
|00003c50| 6f 20 73 6f 6d 65 0d 0a | 6f 66 20 74 68 65 20 70 |o some..|of the p|
|00003c60| 72 69 76 61 74 65 20 6d | 65 6d 62 65 72 73 20 6f |rivate m|embers o|
|00003c70| 66 20 74 68 65 20 6d 61 | 74 72 69 78 20 63 6c 61 |f the ma|trix cla|
|00003c80| 73 73 2e 20 49 74 20 77 | 72 69 74 65 73 20 61 0d |ss. It w|rites a.|
|00003c90| 0a 6d 61 74 72 69 78 20 | 74 6f 20 64 69 73 6b 20 |.matrix |to disk |
|00003ca0| 69 6e 20 61 20 62 69 6e | 61 72 79 20 66 6f 72 6d |in a bin|ary form|
|00003cb0| 2e 20 49 74 20 77 72 69 | 74 65 73 20 74 68 65 20 |. It wri|tes the |
|00003cc0| 64 61 74 61 20 6f 75 74 | 20 69 6e 0d 0a 62 6c 6f |data out| in..blo|
|00003cd0| 63 6b 73 2c 20 72 61 74 | 68 65 72 20 74 68 61 6e |cks, rat|her than|
|00003ce0| 20 65 6c 65 6d 65 6e 74 | 77 69 73 65 2e 20 54 68 | element|wise. Th|
|00003cf0| 65 20 66 69 64 20 69 73 | 20 61 20 66 69 6c 65 20 |e fid is| a file |
|00003d00| 6e 61 6d 65 20 74 6f 0d | 0a 77 72 69 74 65 20 74 |name to.|.write t|
|00003d10| 6f 2e 0d 0a 0d 0a 5c 73 | 65 63 74 69 6f 6e 7b 41 |o.....\s|ection{A|
|00003d20| 72 69 74 68 6d 65 74 69 | 63 20 46 72 69 65 6e 64 |rithmeti|c Friend|
|00003d30| 20 46 75 6e 63 74 69 6f | 6e 73 7d 0d 0a 0d 0a 41 | Functio|ns}....A|
|00003d40| 64 64 69 74 69 6f 6e 2c | 20 73 75 62 74 72 61 63 |ddition,| subtrac|
|00003d50| 74 69 6f 6e 2c 20 75 6e | 61 72 79 20 6d 69 6e 75 |tion, un|ary minu|
|00003d60| 73 2c 20 65 6c 65 6d 65 | 6e 74 77 69 73 65 0d 0a |s, eleme|ntwise..|
|00003d70| 6d 75 6c 74 69 70 6c 69 | 63 61 74 69 6f 6e 2c 20 |multipli|cation, |
|00003d80| 65 6c 65 6d 65 6e 74 77 | 69 73 65 20 64 69 76 69 |elementw|ise divi|
|00003d90| 73 69 6f 6e 2c 20 61 6e | 64 20 6d 61 74 72 69 78 |sion, an|d matrix|
|00003da0| 0d 0a 6d 75 6c 74 69 70 | 6c 69 63 61 74 69 6f 6e |..multip|lication|
|00003db0| 20 69 73 20 73 75 70 70 | 6f 72 74 65 64 20 74 68 | is supp|orted th|
|00003dc0| 72 6f 75 67 68 20 66 72 | 69 65 6e 64 0d 0a 66 75 |rough fr|iend..fu|
|00003dd0| 6e 63 74 69 6f 6e 73 5c | 69 6e 64 65 78 7b 56 4d |nctions\|index{VM|
|00003de0| 61 74 72 69 78 21 24 2b | 2c 2d 2c 2a 2c 5c 25 2c |atrix!$+|,-,*,\%,|
|00003df0| 2f 24 7d 2e 20 54 68 65 | 20 66 75 6e 63 74 69 6f |/$}. The| functio|
|00003e00| 6e 73 20 61 6c 6c 6f 77 | 0d 0a 73 63 61 6c 61 72 |ns allow|..scalar|
|00003e10| 20 61 72 67 75 6d 65 6e | 74 73 20 61 73 20 6c 65 | argumen|ts as le|
|00003e20| 66 74 20 6f 72 20 72 69 | 67 68 74 20 6f 70 65 72 |ft or ri|ght oper|
|00003e30| 61 6e 64 73 20 28 65 78 | 63 65 70 74 20 66 6f 72 |ands (ex|cept for|
|00003e40| 0d 0a 73 63 61 6c 61 72 | 20 64 69 76 69 73 69 6f |..scalar| divisio|
|00003e50| 6e 2e 20 54 68 65 20 6e | 75 6d 65 72 61 74 6f 72 |n. The n|umerator|
|00003e60| 20 63 61 6e 27 74 20 62 | 65 20 61 20 73 63 61 6c | can't b|e a scal|
|00003e70| 61 72 2e 29 2e 20 54 68 | 65 0d 0a 6f 6e 6c 79 20 |ar.). Th|e..only |
|00003e80| 75 6e 75 73 75 61 6c 20 | 66 65 61 74 75 72 65 20 |unusual |feature |
|00003e90| 6f 66 20 74 68 65 73 65 | 20 6f 70 65 72 61 74 6f |of these| operato|
|00003ea0| 72 73 20 69 73 20 74 68 | 65 20 65 6c 65 6d 65 6e |rs is th|e elemen|
|00003eb0| 74 77 69 73 65 0d 0a 6d | 75 6c 74 69 70 6c 69 63 |twise..m|ultiplic|
|00003ec0| 61 74 69 6f 6e 20 69 73 | 20 63 61 6c 6c 65 64 20 |ation is| called |
|00003ed0| 75 73 69 6e 67 20 74 68 | 65 20 27 5c 25 27 20 28 |using th|e '\%' (|
|00003ee0| 61 6d 70 65 72 73 61 6e | 64 29 0d 0a 6f 70 65 72 |ampersan|d)..oper|
|00003ef0| 61 74 6f 72 2e 20 54 68 | 65 79 20 61 6c 6c 20 72 |ator. Th|ey all r|
|00003f00| 65 74 75 72 6e 20 56 4d | 61 74 72 69 78 20 72 65 |eturn VM|atrix re|
|00003f10| 66 65 72 65 6e 63 65 73 | 2e 20 53 65 65 0d 0a 53 |ferences|. See..S|
|00003f20| 68 69 6c 64 74 5c 63 69 | 74 65 7b 73 68 3a 63 2b |hildt\ci|te{sh:c+|
|00003f30| 2b 7d 20 66 6f 72 20 61 | 6e 20 65 78 70 6c 61 6e |+} for a|n explan|
|00003f40| 61 74 69 6f 6e 20 6f 66 | 20 68 6f 77 20 61 6e 64 |ation of| how and|
|00003f50| 20 77 68 79 0d 0a 66 72 | 69 65 6e 64 20 66 75 6e | why..fr|iend fun|
|00003f60| 63 74 69 6f 6e 73 20 61 | 72 65 20 6e 65 65 64 65 |ctions a|re neede|
|00003f70| 64 20 74 6f 20 6f 76 65 | 72 6c 6f 61 64 20 74 68 |d to ove|rload th|
|00003f80| 65 73 65 20 66 75 6e 63 | 74 69 6f 6e 73 2e 0d 0a |ese func|tions...|
|00003f90| 0d 0a 49 6e 20 67 65 6e | 65 72 61 6c 2c 20 74 68 |..In gen|eral, th|
|00003fa0| 65 73 65 20 66 75 6e 63 | 74 69 6f 6e 73 20 66 6f |ese func|tions fo|
|00003fb0| 6c 6c 6f 77 20 74 68 65 | 20 73 61 6d 65 20 70 72 |llow the| same pr|
|00003fc0| 65 63 65 64 65 6e 63 65 | 20 61 73 0d 0a 74 68 65 |ecedence| as..the|
|00003fd0| 20 73 74 61 6e 64 61 72 | 64 20 66 75 6e 63 74 69 | standar|d functi|
|00003fe0| 6f 6e 73 20 6f 6e 20 64 | 6f 75 62 6c 65 73 2e 20 |ons on d|oubles. |
|00003ff0| 54 68 65 79 20 61 6c 73 | 6f 20 70 72 6f 64 75 63 |They als|o produc|
|00004000| 65 0d 0a 69 6e 74 65 72 | 6d 65 64 69 61 74 65 20 |e..inter|mediate |
|00004010| 76 61 6c 75 65 73 20 6f | 6e 20 74 68 65 20 73 74 |values o|n the st|
|00004020| 61 63 6b 2e 20 54 68 65 | 20 63 6f 64 65 20 66 6f |ack. The| code fo|
|00004030| 72 20 61 64 64 69 74 69 | 6f 6e 20 69 73 0d 0a 67 |r additi|on is..g|
|00004040| 69 76 65 6e 20 62 79 0d | 0a 5c 62 65 67 69 6e 7b |iven by.|.\begin{|
|00004050| 76 65 72 62 61 74 69 6d | 7d 0d 0a 56 4d 61 74 72 |verbatim|}..VMatr|
|00004060| 69 78 26 20 6f 70 65 72 | 61 74 6f 72 2b 20 28 56 |ix& oper|ator+ (V|
|00004070| 4d 61 74 72 69 78 20 26 | 4c 4f 70 2c 20 56 4d 61 |Matrix &|LOp, VMa|
|00004080| 74 72 69 78 20 26 52 4f | 70 29 0d 0a 20 20 7b 0d |trix &RO|p).. {.|
|00004090| 0a 20 20 20 20 4c 4f 70 | 2e 47 61 72 62 61 67 65 |. LOp|.Garbage|
|000040a0| 28 22 6f 70 65 72 61 74 | 6f 72 20 2b 22 29 3b 0d |("operat|or +");.|
|000040b0| 0a 20 20 20 20 52 4f 70 | 2e 47 61 72 62 61 67 65 |. ROp|.Garbage|
|000040c0| 28 22 6f 70 65 72 61 74 | 6f 72 20 2b 22 29 3b 0d |("operat|or +");.|
|000040d0| 0a 20 20 20 20 69 66 20 | 28 4c 4f 70 2e 72 3d 3d |. if |(LOp.r==|
|000040e0| 52 4f 70 2e 72 20 26 26 | 20 4c 4f 70 2e 63 3d 3d |ROp.r &&| LOp.c==|
|000040f0| 52 4f 70 2e 63 29 20 7b | 0d 0a 20 20 20 20 20 20 |ROp.c) {|.. |
|00004100| 56 4d 61 74 72 69 78 20 | 2a 74 65 6d 70 20 3d 20 |VMatrix |*temp = |
|00004110| 6e 65 77 20 56 4d 61 74 | 72 69 78 28 22 28 22 2c |new VMat|rix("(",|
|00004120| 20 4c 4f 70 2e 72 2c 20 | 52 4f 70 2e 63 29 3b 0d | LOp.r, |ROp.c);.|
|00004130| 0a 20 20 20 20 20 20 66 | 6f 72 20 28 69 6e 74 20 |. f|or (int |
|00004140| 69 3d 31 3b 20 69 3c 3d | 4c 4f 70 2e 72 3b 20 2b |i=1; i<=|LOp.r; +|
|00004150| 2b 69 29 20 7b 0d 0a 20 | 20 20 20 20 20 20 20 20 |+i) {.. | |
|00004160| 20 66 6f 72 20 28 69 6e | 74 20 6a 3d 31 3b 20 6a | for (in|t j=1; j|
|00004170| 3c 3d 52 4f 70 2e 63 3b | 20 2b 2b 6a 29 20 7b 0d |<=ROp.c;| ++j) {.|
|00004180| 0a 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 74 |. | t|
|00004190| 65 6d 70 2d 3e 4d 28 69 | 2c 6a 29 20 3d 20 4c 4f |emp->M(i|,j) = LO|
|000041a0| 70 2e 6d 28 69 2c 6a 29 | 20 2b 20 52 4f 70 2e 6d |p.m(i,j)| + ROp.m|
|000041b0| 28 69 2c 6a 29 3b 0d 0a | 20 20 20 20 20 20 20 20 |(i,j);..| |
|000041c0| 20 20 7d 0d 0a 20 20 20 | 20 20 20 7d 0d 0a 20 20 | }.. | }.. |
|000041d0| 20 20 20 20 74 65 6d 70 | 2d 3e 6e 61 6d 65 20 3d | temp|->name =|
|000041e0| 20 74 65 6d 70 2d 3e 6e | 61 6d 65 2b 4c 4f 70 2e | temp->n|ame+LOp.|
|000041f0| 6e 61 6d 65 2b 22 2b 22 | 2b 52 4f 70 2e 6e 61 6d |name+"+"|+ROp.nam|
|00004200| 65 2b 22 29 22 3b 0d 0a | 20 20 20 20 20 20 44 69 |e+")";..| Di|
|00004210| 73 70 61 74 63 68 2d 3e | 50 75 73 68 28 2a 74 65 |spatch->|Push(*te|
|00004220| 6d 70 29 3b 0d 0a 20 20 | 20 20 20 20 64 65 6c 65 |mp);.. | dele|
|00004230| 74 65 20 74 65 6d 70 3b | 0d 0a 20 20 20 20 20 20 |te temp;|.. |
|00004240| 72 65 74 75 72 6e 20 20 | 44 69 73 70 61 74 63 68 |return |Dispatch|
|00004250| 2d 3e 52 65 74 75 72 6e | 4d 61 74 28 29 3b 0d 0a |->Return|Mat();..|
|00004260| 20 20 20 20 7d 0d 0a 20 | 20 65 6c 73 65 20 52 4f | }.. | else RO|
|00004270| 70 2e 4e 72 65 72 72 6f | 72 28 22 4d 69 73 6d 61 |p.Nrerro|r("Misma|
|00004280| 74 63 68 65 64 20 4d 61 | 74 72 69 78 20 73 69 7a |tched Ma|trix siz|
|00004290| 65 73 20 69 6e 20 61 64 | 64 69 74 69 6f 6e 20 66 |es in ad|dition f|
|000042a0| 75 6e 63 74 69 6f 6e 5c | 6e 22 29 3b 0d 0a 20 20 |unction\|n");.. |
|000042b0| 7d 0d 0a 5c 65 6e 64 7b | 76 65 72 62 61 74 69 6d |}..\end{|verbatim|
|000042c0| 7d 0d 0a 54 68 65 20 66 | 75 6e 63 74 69 6f 6e 20 |}..The f|unction |
|000042d0| 66 69 72 73 74 20 63 68 | 65 63 6b 73 20 74 68 65 |first ch|ecks the|
|000042e0| 20 76 61 6c 69 64 69 74 | 79 20 6f 66 20 69 74 73 | validit|y of its|
|000042f0| 20 6f 70 65 72 61 6e 64 | 73 2e 20 49 74 0d 0a 61 | operand|s. It..a|
|00004300| 6c 73 6f 20 63 68 65 63 | 6b 73 20 74 68 61 74 20 |lso chec|ks that |
|00004310| 74 68 65 20 6d 61 74 72 | 69 63 65 73 20 61 72 65 |the matr|ices are|
|00004320| 20 63 6f 6e 66 6f 72 6d | 61 62 6c 65 2e 20 49 66 | conform|able. If|
|00004330| 20 74 68 65 79 20 61 72 | 65 2c 0d 0a 61 20 6e 65 | they ar|e,..a ne|
|00004340| 77 20 6d 61 74 72 69 78 | 20 69 73 20 70 75 74 20 |w matrix| is put |
|00004350| 6f 6e 20 74 68 65 20 68 | 65 61 70 2e 20 54 68 65 |on the h|eap. The|
|00004360| 20 6d 61 74 72 69 63 65 | 73 20 61 72 65 20 73 75 | matrice|s are su|
|00004370| 6d 6d 65 64 2e 0d 0a 4e | 6f 74 65 20 74 68 65 20 |mmed...N|ote the |
|00004380| 75 73 65 20 6f 66 20 74 | 68 65 20 6c 69 74 74 6c |use of t|he littl|
|00004390| 65 20 6d 28 69 2c 6a 29 | 20 6f 6e 20 74 68 65 20 |e m(i,j)| on the |
|000043a0| 72 69 67 68 74 20 73 69 | 64 65 20 6f 66 20 74 68 |right si|de of th|
|000043b0| 65 0d 0a 73 75 6d 2c 20 | 61 6e 64 20 74 68 65 20 |e..sum, |and the |
|000043c0| 4d 28 69 2c 6a 29 20 6f | 6e 20 74 68 65 20 6c 65 |M(i,j) o|n the le|
|000043d0| 66 74 2e 20 54 68 65 20 | 6e 61 6d 65 20 69 73 20 |ft. The |name is |
|000043e0| 63 72 65 61 74 65 64 2e | 20 54 68 65 0d 0a 6d 61 |created.| The..ma|
|000043f0| 74 72 69 78 20 69 73 20 | 70 75 73 68 65 64 20 6f |trix is |pushed o|
|00004400| 6e 74 6f 20 74 68 65 20 | 73 74 61 63 6b 2c 20 74 |nto the |stack, t|
|00004410| 68 65 6e 20 64 65 6c 65 | 74 65 64 2e 20 0d 0a 0d |hen dele|ted. ...|
|00004420| 0a 54 68 65 20 72 65 66 | 65 72 65 6e 63 65 20 72 |.The ref|erence r|
|00004430| 65 74 75 72 6e 65 64 20 | 69 73 20 74 68 65 20 6d |eturned |is the m|
|00004440| 61 74 72 69 78 20 70 6f | 69 6e 74 65 64 20 74 6f |atrix po|inted to|
|00004450| 20 62 79 0d 0a 5c 76 65 | 72 62 23 20 44 69 73 70 | by..\ve|rb# Disp|
|00004460| 61 74 63 68 2d 3e 6e 65 | 78 74 23 2e 20 54 68 65 |atch->ne|xt#. The|
|00004470| 20 66 75 6e 63 74 69 6f | 6e 20 52 65 74 75 72 6e | functio|n Return|
|00004480| 4d 61 74 28 29 20 70 61 | 73 73 65 73 20 74 68 65 |Mat() pa|sses the|
|00004490| 20 6d 61 74 72 69 78 0d | 0a 72 65 66 65 72 65 6e | matrix.|.referen|
|000044a0| 63 65 2c 20 61 6e 64 20 | 64 6f 65 73 20 6e 6f 74 |ce, and |does not|
|000044b0| 20 63 68 61 6e 67 65 20 | 74 68 65 20 66 75 6e 63 | change |the func|
|000044c0| 74 69 6f 6e 20 6e 65 73 | 74 69 6e 67 20 6c 65 76 |tion nes|ting lev|
|000044d0| 65 6c 2e 0d 0a 42 61 73 | 69 63 61 6c 6c 79 2c 20 |el...Bas|ically, |
|000044e0| 74 68 65 20 6e 65 73 74 | 69 6e 67 20 6c 65 76 65 |the nest|ing leve|
|000044f0| 6c 20 6b 65 65 70 73 20 | 74 72 61 63 6b 20 6f 66 |l keeps |track of|
|00004500| 20 74 68 65 20 66 75 6e | 63 74 69 6f 6e 0d 0a 64 | the fun|ction..d|
|00004510| 65 70 74 68 20 77 68 65 | 72 65 20 61 64 64 69 74 |epth whe|re addit|
|00004520| 69 6f 6e 20 77 61 73 20 | 63 61 6c 6c 65 64 2e 20 |ion was |called. |
|00004530| 41 6c 73 6f 2c 20 43 6c | 65 61 6e 73 74 61 63 6b |Also, Cl|eanstack|
|00004540| 28 29 20 75 73 65 73 0d | 0a 74 68 65 20 6e 65 73 |() uses.|.the nes|
|00004550| 74 69 6e 67 20 6c 65 76 | 65 6c 20 74 6f 20 64 65 |ting lev|el to de|
|00004560| 74 65 72 6d 69 6e 65 20 | 77 68 69 63 68 20 6d 61 |termine |which ma|
|00004570| 74 72 69 63 65 73 20 74 | 6f 20 73 74 72 69 70 20 |trices t|o strip |
|00004580| 66 72 6f 6d 0d 0a 74 68 | 65 20 73 74 61 63 6b 2e |from..th|e stack.|
|00004590| 20 53 79 73 74 65 6d 20 | 66 75 6e 63 74 69 6f 6e | System |function|
|000045a0| 73 20 73 68 6f 75 6c 64 | 20 75 73 65 20 52 65 74 |s should| use Ret|
|000045b0| 75 72 6e 4d 61 74 28 29 | 20 72 61 74 68 65 72 0d |urnMat()| rather.|
|000045c0| 0a 74 68 61 6e 20 44 65 | 63 52 65 74 75 72 6e 28 |.than De|cReturn(|
|000045d0| 29 2e 20 20 44 65 63 52 | 65 74 75 72 6e 28 29 20 |). DecR|eturn() |
|000045e0| 64 65 63 72 65 6d 65 6e | 74 73 20 74 68 65 20 6e |decremen|ts the n|
|000045f0| 65 73 74 69 6e 67 0d 0a | 6c 65 76 65 6c 2c 20 74 |esting..|level, t|
|00004600| 68 65 6e 20 72 65 74 75 | 72 6e 73 20 74 68 65 20 |hen retu|rns the |
|00004610| 63 6f 72 72 65 63 74 20 | 6d 61 74 72 69 78 20 72 |correct |matrix r|
|00004620| 65 66 65 72 65 6e 63 65 | 2e 20 4d 6f 72 65 0d 0a |eference|. More..|
|00004630| 61 62 6f 75 74 20 74 68 | 69 73 20 69 6e 20 74 68 |about th|is in th|
|00004640| 65 20 6e 65 78 74 20 63 | 68 61 70 74 65 72 2e 20 |e next c|hapter. |
|00004650| 54 68 65 20 77 61 79 20 | 74 6f 20 74 65 6c 6c 20 |The way |to tell |
|00004660| 77 68 65 6e 20 74 6f 20 | 75 73 65 0d 0a 44 65 63 |when to |use..Dec|
|00004670| 52 65 74 75 72 6e 28 29 | 20 69 73 20 69 66 20 79 |Return()| is if y|
|00004680| 6f 75 20 65 6e 74 65 72 | 20 74 68 65 20 66 75 6e |ou enter| the fun|
|00004690| 63 74 69 6f 6e 20 61 6e | 64 20 63 61 6c 6c 0d 0a |ction an|d call..|
|000046a0| 49 6e 63 6c 65 76 65 6c | 28 29 2e 20 55 73 69 6e |Inclevel|(). Usin|
|000046b0| 67 20 74 68 65 20 73 74 | 61 63 6b 20 61 6c 6c 6f |g the st|ack allo|
|000046c0| 77 73 20 74 68 65 20 66 | 75 6e 63 74 69 6f 6e 73 |ws the f|unctions|
|000046d0| 20 74 6f 20 62 65 20 72 | 65 63 75 72 73 69 76 65 | to be r|ecursive|
|000046e0| 2e | |. | |
+--------+-------------------------+-------------------------+--------+--------+